Exemple #1
0
 public void OnDestroy()
 {
     try
     {
         try
         {
             if (sensationCoreInterop_ != null)
             {
                 sensationCoreInterop_.uhsclRelease(sensationCoreInstancePtr_);
                 sensationCoreInterop_     = null;
                 SensationCore.Instance    = null;
                 sensationCoreInstancePtr_ = default(IntPtr);
             }
         }
         catch
         {
             ReleaseEmitter();
             sensationCoreInterop_.uhsclRelease(sensationCoreInstancePtr_);
             sensationCoreInterop_     = null;
             SensationCore.Instance    = null;
             sensationCoreInstancePtr_ = default(IntPtr);
         }
     }
     catch (Exception e)
     {
         UCA.Logger.LogInfo("Exception when destroying SensationCore: " + e);
     }
 }
Exemple #2
0
        public void CreateSensationCore(ISensationCoreInterop SensationCoreInterop = null)
        {
            try
            {
                if (SensationCore.Instance == null)
                {
                    if (SensationCoreInterop == null)
                    {
                        sensationCoreInterop_ = new SensationCoreInterop();
                        sensationCoreInterop_ = new LockDecorator(sensationCoreInterop_);
                        sensationCoreInterop_ = new ThrowOnErrorDecorator(sensationCoreInterop_);
                        sensationCoreInterop_ = new ForwardLogMessagesDecorator(sensationCoreInterop_, new LogStreamReader(sensationCoreInterop_));
                    }
                    else
                    {
                        sensationCoreInterop_ = SensationCoreInterop;
                    }
                    sensationCoreInstancePtr_ = sensationCoreInterop_.uhsclCreate();
                    if (sensationCoreInstancePtr_ == default(IntPtr))
                    {
                        throw new Exception("Failed to initialise SensationCore library");
                    }

                    foreach (var method in onSensationCoreInitializeUserMethods_)
                    {
                        try
                        {
                            method.Invoke(null, null);
                        }
                        catch (Exception ex)
                        {
                            UCA.Logger.LogWarning("Failed executing OnSensationCoreInitialize Method : " + method.Name + "\n" + ex.InnerException ?? ex.Message);
                        }
                    }

                    pythonSearchPaths_.ResetApplied();
                    pythonSearchPaths_.Apply(sensationCoreInterop_, sensationCoreInstancePtr_);
                    pythonSearchPaths_.DisplayWarningIfNoSearchPathsAreValid();

                    Instance = this;
                    if (Application.isPlaying)
                    {
                        UCA.Logger.LogInfo("SensationCore Successfully Created");
                    }
                }
            }
            catch (Exception e)
            {
                UCA.Logger.LogInfo("Exception creating SensationCore: " + e);
            }
        }