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.

81 lines
3.0 KiB

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine.XR.ARSubsystems;
  4. namespace UnityEngine.XR.ARFoundation
  5. {
  6. /// <summary>
  7. /// A manager for <see cref="ARParticipant"/>s. Creates, updates, and removes
  8. /// <c>GameObject</c>s in response to other users in a multi-user collaborative session.
  9. /// </summary>
  10. [DefaultExecutionOrder(ARUpdateOrder.k_ParticipantManager)]
  11. [DisallowMultipleComponent]
  12. [RequireComponent(typeof(ARSessionOrigin))]
  13. [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@3.0/api/UnityEngine.XR.ARFoundation.ARParticipantManager.html")]
  14. public sealed class ARParticipantManager : ARTrackableManager<
  15. XRParticipantSubsystem,
  16. XRParticipantSubsystemDescriptor,
  17. XRParticipant,
  18. ARParticipant>
  19. {
  20. [SerializeField]
  21. [Tooltip("(Optional) Instantiates this prefab for each participant.")]
  22. GameObject m_ParticipantPrefab;
  23. /// <summary>
  24. /// (Optional) Instantiates this prefab for each participant. If <c>null</c>, an empty <c>GameObject</c>
  25. /// with a <see cref="ARParticipant"/> component is instantiated instead.
  26. /// </summary>
  27. public GameObject participantPrefab
  28. {
  29. get { return m_ParticipantPrefab; }
  30. set { m_ParticipantPrefab = value; }
  31. }
  32. /// <summary>
  33. /// Invoked when participants have changed (been added, updated, or removed).
  34. /// </summary>
  35. public event Action<ARParticipantsChangedEventArgs> participantsChanged;
  36. /// <summary>
  37. /// Attempt to retrieve an existing <see cref="ARParticipant"/> by <paramref name="trackableId"/>.
  38. /// </summary>
  39. /// <param name="trackableId">The <see cref="TrackableId"/> of the participant to retrieve.</param>
  40. /// <returns>The <see cref="ARParticipant"/> with <paramref name="trackableId"/>, or <c>null</c> if it does not exist.</returns>
  41. public ARParticipant GetParticipant(TrackableId trackableId)
  42. {
  43. if (m_Trackables.TryGetValue(trackableId, out ARParticipant participant))
  44. return participant;
  45. return null;
  46. }
  47. protected override GameObject GetPrefab()
  48. {
  49. return m_ParticipantPrefab;
  50. }
  51. protected override void OnTrackablesChanged(
  52. List<ARParticipant> added,
  53. List<ARParticipant> updated,
  54. List<ARParticipant> removed)
  55. {
  56. if (participantsChanged != null)
  57. {
  58. participantsChanged(
  59. new ARParticipantsChangedEventArgs(
  60. added,
  61. updated,
  62. removed));
  63. }
  64. }
  65. /// <summary>
  66. /// The name to be used for the <c>GameObject</c> whenever a new participant is detected.
  67. /// </summary>
  68. protected override string gameObjectName
  69. {
  70. get { return "ARParticipant"; }
  71. }
  72. }
  73. }