/// <summary>
                /// Unsubscribes from pause and lifecycle events.
                /// </summary>
                internal void Cleanup()
                {
                    // While local tracks can be unsubscribed in the DestroyLocal(), the only place to do that for remote tracks is in the finalizer.
#if PLATFORM_LUMIN
                    UnityEngine.Lumin.Lifecycle.deviceStandbyEvent -= this.HandleDeviceStandby;
                    UnityEngine.Lumin.Lifecycle.deviceRealityEvent -= this.HandleDeviceReality;
                    UnityEngine.Lumin.Lifecycle.deviceActiveEvent  -= this.HandleDeviceActive;
                    MLDevice.UnregisterApplicationPause(this.OnApplicationPause);
#endif
                }
Exemplo n.º 2
0
        /// <summary>
        /// Decrement API instance count and cleanup if this is the last one.
        /// </summary>
        private void StopAPI()
        {
            if (startCount > 0)
            {
                --startCount;
                if (startCount == 0)
                {
                    MLDevice.UnregisterUpdate(this.Update);
                    MLDevice.UnregisterApplicationPause(this.OnApplicationPause);
                    this.CleanupAPI(true);

                    if (this.perceptionHasStarted)
                    {
                        this.perceptionHandle.Dispose();
                        this.perceptionHasStarted = false;
                    }

                    _instance = null;
                }
            }
        }
        private void StopInternal()
        {
            if (IsStarted)
            {
                MLDevice.UnregisterUpdate(this.Update);
                MLDevice.UnregisterApplicationPause(this.OnApplicationPause);
                MLDevice.UnregisterDestroy(instance.StopInternal);

                MLResult.Code resultCode = instance.StopAPI();

                if (DidNativeCallSucceed(resultCode, $"{typeof(T).Name} Stop"))
                {
                    MLPluginLog.Debug($"{typeof(T).Name} API stopped successfully");
                }

                if (perceptionHandle.active)
                {
                    perceptionHandle.Dispose();
                }

                IsStarted = false;
            }
        }