SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
4.4 KiB

4 years ago
  1. using System;
  2. using Unity.Collections;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// Subsystem for managing the participants in a multi-user collaborative session.
  7. /// </summary>
  8. public abstract class XRParticipantSubsystem : TrackingSubsystem<XRParticipant, XRParticipantSubsystemDescriptor>
  9. {
  10. /// <summary>
  11. /// Do not call this directly. Call create on a valid <see cref="XRParticipantSubsystemDescriptor"/> instead.
  12. /// </summary>
  13. public XRParticipantSubsystem() => m_Provider = CreateProvider();
  14. /// <summary>
  15. /// Starts the participant subsystem.
  16. /// </summary>
  17. protected sealed override void OnStart() => m_Provider.Start();
  18. /// <summary>
  19. /// Stops the participant subsystem.
  20. /// </summary>
  21. protected sealed override void OnStop() => m_Provider.Stop();
  22. /// <summary>
  23. /// Destroys the participant subsystem.
  24. /// </summary>
  25. protected sealed override void OnDestroyed() => m_Provider.Destroy();
  26. /// <summary>
  27. /// Get the changed (added, updated, and removed) participants since the last call to <see cref="GetChanges(Allocator)"/>.
  28. /// </summary>
  29. /// <param name="allocator">An <c>Allocator</c> to use when allocating the returned <c>NativeArray</c>s.</param>
  30. /// <returns>
  31. /// <see cref="TrackableChanges{T}"/> describing the participants that have been added, updated, and removed
  32. /// since the last call to <see cref="GetChanges(Allocator)"/>. The caller owns the memory allocated with <c>Allocator</c>.
  33. /// </returns>
  34. public override TrackableChanges<XRParticipant> GetChanges(Allocator allocator)
  35. {
  36. var changes = m_Provider.GetChanges(XRParticipant.defaultParticipant, allocator);
  37. #if DEVELOPMENT_BUILD || UNITY_EDITOR
  38. m_ValidationUtility.ValidateAndDisposeIfThrown(changes);
  39. #endif
  40. return changes;
  41. }
  42. /// <summary>
  43. /// Implement this to provide this class with an interface to platform specific implementations.
  44. /// </summary>
  45. /// <returns>An implementation specific provider.</returns>
  46. protected abstract Provider CreateProvider();
  47. /// <summary>
  48. /// The API this subsystem uses to interop with different provider implementations.
  49. /// </summary>
  50. protected abstract class Provider
  51. {
  52. /// <summary>
  53. /// Invoked to start the participant subsystem.
  54. /// </summary>
  55. public virtual void Start()
  56. { }
  57. /// <summary>
  58. /// Invoked to stop the participant subsystem.
  59. /// </summary>
  60. public virtual void Stop()
  61. { }
  62. /// <summary>
  63. /// Invoked to shutdown and destroy the participant subsystem. The implementation should release any
  64. /// resources required by the subsystem. If the subsystem is running, <see cref="Stop"/> will always
  65. /// be called before <see cref="Destroy"/>.
  66. /// </summary>
  67. public virtual void Destroy()
  68. { }
  69. /// <summary>
  70. /// Get the changed (added, updated, and removed) participants since the last call to <see cref="GetChanges(Allocator)"/>.
  71. /// </summary>
  72. /// <param name="defaultParticipant">
  73. /// The default participant. This should be used to initialize the returned <c>NativeArray</c>s for backwards compatibility.
  74. /// See <see cref="TrackableChanges{T}.TrackableChanges(void*, int, void*, int, void*, int, T, int, Allocator)"/>.
  75. /// </param>
  76. /// <param name="allocator">An <c>Allocator</c> to use when allocating the returned <c>NativeArray</c>s.</param>
  77. /// <returns>
  78. /// <see cref="TrackableChanges{T}"/> describing the participants that have been added, updated, and removed
  79. /// since the last call to <see cref="GetChanges(Allocator)"/>. The changes should be allocated using
  80. /// <paramref name="allocator"/>.
  81. /// </returns>
  82. public abstract TrackableChanges<XRParticipant> GetChanges(
  83. XRParticipant defaultParticipant,
  84. Allocator allocator);
  85. }
  86. Provider m_Provider;
  87. #if DEVELOPMENT_BUILD || UNITY_EDITOR
  88. ValidationUtility<XRParticipant> m_ValidationUtility = new ValidationUtility<XRParticipant>();
  89. #endif
  90. }
  91. }