using System; using Unity.Collections; namespace UnityEngine.XR.ARSubsystems { /// /// Subsystem for managing the participants in a multi-user collaborative session. /// public abstract class XRParticipantSubsystem : TrackingSubsystem { /// /// Do not call this directly. Call create on a valid instead. /// public XRParticipantSubsystem() => m_Provider = CreateProvider(); /// /// Starts the participant subsystem. /// protected sealed override void OnStart() => m_Provider.Start(); /// /// Stops the participant subsystem. /// protected sealed override void OnStop() => m_Provider.Stop(); /// /// Destroys the participant subsystem. /// protected sealed override void OnDestroyed() => m_Provider.Destroy(); /// /// Get the changed (added, updated, and removed) participants since the last call to . /// /// An Allocator to use when allocating the returned NativeArrays. /// /// describing the participants that have been added, updated, and removed /// since the last call to . The caller owns the memory allocated with Allocator. /// public override TrackableChanges GetChanges(Allocator allocator) { var changes = m_Provider.GetChanges(XRParticipant.defaultParticipant, allocator); #if DEVELOPMENT_BUILD || UNITY_EDITOR m_ValidationUtility.ValidateAndDisposeIfThrown(changes); #endif return changes; } /// /// Implement this to provide this class with an interface to platform specific implementations. /// /// An implementation specific provider. protected abstract Provider CreateProvider(); /// /// The API this subsystem uses to interop with different provider implementations. /// protected abstract class Provider { /// /// Invoked to start the participant subsystem. /// public virtual void Start() { } /// /// Invoked to stop the participant subsystem. /// public virtual void Stop() { } /// /// Invoked to shutdown and destroy the participant subsystem. The implementation should release any /// resources required by the subsystem. If the subsystem is running, will always /// be called before . /// public virtual void Destroy() { } /// /// Get the changed (added, updated, and removed) participants since the last call to . /// /// /// The default participant. This should be used to initialize the returned NativeArrays for backwards compatibility. /// See . /// /// An Allocator to use when allocating the returned NativeArrays. /// /// describing the participants that have been added, updated, and removed /// since the last call to . The changes should be allocated using /// . /// public abstract TrackableChanges GetChanges( XRParticipant defaultParticipant, Allocator allocator); } Provider m_Provider; #if DEVELOPMENT_BUILD || UNITY_EDITOR ValidationUtility m_ValidationUtility = new ValidationUtility(); #endif } }