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.

115 lines
4.4 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// Descriptor for the <see cref="XRRaycastSubsystem"/>. Describes capabilities of a specific raycast provider.
  6. /// </summary>
  7. public sealed class XRRaycastSubsystemDescriptor : SubsystemDescriptor<XRRaycastSubsystem>
  8. {
  9. /// <summary>
  10. /// Used to register a descriptor. See <see cref="RegisterDescriptor(Cinfo)"/>.
  11. /// </summary>
  12. public struct Cinfo : IEquatable<Cinfo>
  13. {
  14. /// <summary>
  15. /// A provider-specific identifier.
  16. /// </summary>
  17. public string id { get; set; }
  18. /// <summary>
  19. /// The <c>Type</c> of the subsystem.
  20. /// </summary>
  21. public Type subsystemImplementationType { get; set; }
  22. /// <summary>
  23. /// Whether the provider supports casting a ray from a screen point.
  24. /// </summary>
  25. public bool supportsViewportBasedRaycast { get; set; }
  26. /// <summary>
  27. /// Whether the provider supports casting an arbitrary ray.
  28. /// </summary>
  29. public bool supportsWorldBasedRaycast { get; set; }
  30. /// <summary>
  31. /// The types of trackables against which raycasting is supported.
  32. /// </summary>
  33. public TrackableType supportedTrackableTypes { get; set; }
  34. public override int GetHashCode()
  35. {
  36. unchecked
  37. {
  38. var hash = (id == null) ? 0 : id.GetHashCode();
  39. hash = hash * 486187739 + ((subsystemImplementationType == null) ? 0 : subsystemImplementationType.GetHashCode());
  40. hash = hash * 486187739 + supportsViewportBasedRaycast.GetHashCode();
  41. hash = hash * 486187739 + supportsWorldBasedRaycast.GetHashCode();
  42. hash = hash * 486187739 + supportedTrackableTypes.GetHashCode();
  43. return hash;
  44. }
  45. }
  46. public override bool Equals(object obj)
  47. {
  48. if (!(obj is Cinfo))
  49. return false;
  50. return Equals((Cinfo)obj);
  51. }
  52. public override string ToString()
  53. {
  54. return string.Format("XRRaycastSubsystemDescriptor:\nsupportsViewportBasedRaycast: {0}\nsupportsWorldBasedRaycast: {1}",
  55. supportsViewportBasedRaycast, supportsWorldBasedRaycast);
  56. }
  57. public bool Equals(Cinfo other)
  58. {
  59. return
  60. String.Equals(id, other.id) &&
  61. (subsystemImplementationType == other.subsystemImplementationType) &&
  62. (supportsViewportBasedRaycast == other.supportsViewportBasedRaycast) &&
  63. (supportsWorldBasedRaycast == other.supportsWorldBasedRaycast) &&
  64. (supportedTrackableTypes == other.supportedTrackableTypes);
  65. }
  66. public static bool operator ==(Cinfo lhs, Cinfo rhs) { return lhs.Equals(rhs); }
  67. public static bool operator !=(Cinfo lhs, Cinfo rhs) { return !lhs.Equals(rhs); }
  68. }
  69. /// <summary>
  70. /// Whether the provider supports casting a ray from a screen point.
  71. /// </summary>
  72. public bool supportsViewportBasedRaycast { get; private set; }
  73. /// <summary>
  74. /// Whether the provider supports casting an arbitrary ray.
  75. /// </summary>
  76. public bool supportsWorldBasedRaycast { get; private set; }
  77. /// <summary>
  78. /// The types of trackables against which raycasting is supported.
  79. /// </summary>
  80. public TrackableType supportedTrackableTypes { get; private set; }
  81. /// <summary>
  82. /// Registers a new descriptor. Should be called by provider implementations.
  83. /// </summary>
  84. /// <param name="cinfo"></param>
  85. public static void RegisterDescriptor(Cinfo cinfo)
  86. {
  87. SubsystemRegistration.CreateDescriptor(new XRRaycastSubsystemDescriptor(cinfo));
  88. }
  89. XRRaycastSubsystemDescriptor(Cinfo cinfo)
  90. {
  91. id = cinfo.id;
  92. subsystemImplementationType = cinfo.subsystemImplementationType;
  93. supportsViewportBasedRaycast = cinfo.supportsViewportBasedRaycast;
  94. supportsWorldBasedRaycast = cinfo.supportsWorldBasedRaycast;
  95. supportedTrackableTypes = cinfo.supportedTrackableTypes;
  96. }
  97. }
  98. }