namespace UnityEngine.XR.ARSubsystems { /// /// Serves as the base class for all the /// [subsystems](https://docs.unity3d.com/ScriptReference/Subsystem.html) /// in this package. /// /// The /// [Subsystem Descriptor](https://docs.unity3d.com/ScriptReference/SubsystemDescriptor.html) /// for the /// [Subsystem](https://docs.unity3d.com/ScriptReference/Subsystem.html) /// public abstract class XRSubsystem : Subsystem where TSubsystemDescriptor : ISubsystemDescriptor { /// /// Invoked when is called and is false. /// protected abstract void OnStart(); /// /// Invoked when is called and is true. /// protected abstract void OnStop(); /// /// Invoked when [Destroy](https://docs.unity3d.com/ScriptReference/Subsystem.Destroy.html) /// is called. This method will not be invoked more than once, even if Destroy is /// called multiple times. /// protected abstract void OnDestroyed(); /// /// true if the Subsystem has been Started and is currently running, /// otherwise false. /// public sealed override bool running => m_Running; bool m_Running; #if !UNITY_2020_1_OR_NEWER bool m_Destroyed; #endif /// /// Destroys the [subsystem](https://docs.unity3d.com/ScriptReference/Subsystem.html). /// If the subsystem is , is also called. /// #if UNITY_2019_3_OR_NEWER protected sealed override void OnDestroy() #else public sealed override void Destroy() #endif { #if !UNITY_2020_1_OR_NEWER // 2020.1 has this logic built into Unity core, but before // that we need to track the destroyed state ourselves. if (m_Destroyed) return; m_Destroyed = true; #endif Stop(); OnDestroyed(); } /// /// Starts the [subsystem](https://docs.unity3d.com/ScriptReference/Subsystem.html). /// public sealed override void Start() { if (!m_Running) { OnStart(); } m_Running = true; } /// /// Stops the [subsystem](https://docs.unity3d.com/ScriptReference/Subsystem.html). /// public sealed override void Stop() { if (m_Running) { OnStop(); } m_Running = false; } } }