Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by imranmouna · Apr 02, 2017 at 10:10 AM · c#referencemonobehavioursingletonconversion

How do I fix this error when trying to use the Watson SDK for Speech to Text?

Hi everyone, thanks for taking a look at this. I'm new to Unity and struggling to understand how to fix this error.

Assets/Watson/Scripts/Logging/Logger.cs(115,53): error CS0311: The type IBM.Watson.DeveloperCloud.Logging.LogSystem' cannot be used as type parameter T in the generic type or method Singleton. There is no implicit reference conversion from IBM.Watson.DeveloperCloud.Logging.LogSystem' to `UnityEngine.MonoBehaviour

This is the line causing the error:

 public static LogSystem Instance { get { return Singleton<LogSystem>.Instance; } }

And this is it in context:

  /// <summary>
   /// This singleton class maintains the of list of installed reactors and handles all LogRecord 
   /// objects. See the static class Log for functions the end user of this system should actually
   /// be calling. This class is thread safe.
   /// </summary>
   public class LogSystem
   {
     #region Public Properties
     /// <summary>
     /// Returns the singleton instance of the Logger object.
     /// </summary>
     **public static LogSystem Instance { get { return Singleton<LogSystem>.Instance; } }**
     #endregion
 
     #region Private Data
     private static bool sm_bInstalledDefaultReactors = false;
     List<ILogReactor> m_Reactors = new List<ILogReactor>();
     #endregion
 
     #region Public Functions
     public static List<ILogReactor> ReactorsInstalled
     {
       get
       {
         return LogSystem.Instance.m_Reactors;
       }
     }
 
     /// <summary>
     /// Install a default debug and file reactor.
     /// </summary>
     public static void InstallDefaultReactors(int logHistory = 2, LogLevel logLevelFileReactor = LogLevel.STATUS)
     {
       if (!sm_bInstalledDefaultReactors)
       {
         // install the default reactors...
         sm_bInstalledDefaultReactors = true;
 #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID
         LogSystem.Instance.InstallReactor(new DebugReactor());
 #endif
 
         if (!string.IsNullOrEmpty(Constants.Path.LOG_FOLDER) && !System.IO.Directory.Exists(Application.persistentDataPath + Constants.Path.LOG_FOLDER))
           System.IO.Directory.CreateDirectory(Application.persistentDataPath + Constants.Path.LOG_FOLDER);
 
         LogSystem.Instance.InstallReactor(new FileReactor(Application.persistentDataPath + Constants.Path.LOG_FOLDER + "/" + Application.productName + ".log", logLevelFileReactor, logHistory));
 
         Application.logMessageReceived += UnityLogCallback;
       }
     }
 
     static void UnityLogCallback(string condition, string stacktrace, LogType type)
     {
       if (type == LogType.Exception)
         Log.Critical("Unity", "Unity Exception {0} : {1}", condition, stacktrace);
     }
 
     /// <summary>
     /// Installs a reactor into this Logger.
     /// </summary>
     /// <param name="reactor">The reactor object.</param>
     public void InstallReactor(ILogReactor reactor)
     {
       lock (m_Reactors)
       {
         m_Reactors.Add(reactor);
       }
       // set our default reactor flag to true if the user installs their own reactors.
       sm_bInstalledDefaultReactors = true;
     }
 
     /// <summary>
     /// Removes a reactor from this Logger.
     /// </summary>
     /// <param name="reactor">The reactor to remove.</param>
     /// <returns>Returns true on success.</returns>
     public bool RemoveReactor(ILogReactor reactor)
     {
       lock (m_Reactors)
       {
         return m_Reactors.Remove(reactor);
       }
     }
 
     /// <summary>
     /// Send the given LogRecord to all installed reactors.
     /// </summary>
     /// <param name="log">The LogRecord to pass to all reactors.</param>
     public void ProcessLog(LogRecord log)
     {
       lock (m_Reactors)
       {
         foreach (var reactor in m_Reactors)
           reactor.ProcessLog(log);
       }
     }
     #endregion
   }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RobAnthem · Apr 02, 2017 at 10:21 AM 0
Share

Seriously... read your error. Line 115 of the class file Logger is referencing a type that is not derived from UnityEngine.Object.$$anonymous$$onoBehaviour, but attempting to use it like it was. The object is IB$$anonymous$$.Watson.DeveloperCloud.Logging.LogSystem, which obviously is not a Unity Object, doesn't matter. The error is clear, and you aren't providing the code from the class file, so there is nothing we can do to help.

avatar image imranmouna RobAnthem · Apr 02, 2017 at 01:53 PM 0
Share

@RobAnthem thanks, I should have watched the "How To Write A Good Question" video first. Hopefully this is better now.

avatar image imranmouna RobAnthem · Apr 02, 2017 at 10:05 PM 0
Share

Okay I made progress by removing the generic singleton declaration.

 public static LogSystem Instance { get { return LogSystem.Instance; } }

But now I'm getting a new error that I'm unsure of how to fix, so I'm not sure if what I did was right.

StackOverflowException: The requested operation caused a stack overflow. IB$$anonymous$$.Watson.DeveloperCloud.Logging.LogSystem.get_Instance () (at Assets/Watson/Scripts/Logging/Logger.cs:115)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a list of singletons? 1 Answer

How can I return a GameObject? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Need suggestion to handle references in Singleton. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges