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.

105 lines
3.8 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// Descriptor for the <see cref="XRSessionSubsystem"/> describing capabilities which may vary by implementation.
  6. /// </summary>
  7. public sealed class XRSessionSubsystemDescriptor : SubsystemDescriptor<XRSessionSubsystem>
  8. {
  9. /// <summary>
  10. /// Whether the session supports the update or installation of session software.
  11. /// </summary>
  12. public bool supportsInstall { get; private set; }
  13. /// <summary>
  14. /// Whether the session supports matching the AR frame rate to the Unity frame rate.
  15. /// </summary>
  16. public bool supportsMatchFrameRate { get; private set; }
  17. /// <summary>
  18. /// Used in conjunction with <see cref="RegisterDescriptor(Cinfo)"/> to register a provider.
  19. /// This should only be used by subsystem implementors.
  20. /// </summary>
  21. public struct Cinfo : IEquatable<Cinfo>
  22. {
  23. /// <summary>
  24. /// Whether the session supports the update or installation of session software.
  25. /// </summary>
  26. public bool supportsInstall { get; set; }
  27. /// <summary>
  28. /// Whether the session supports matching the AR frame rate to the Unity frame rate.
  29. /// </summary>
  30. public bool supportsMatchFrameRate { get; set; }
  31. /// <summary>
  32. /// The string used to identify this subsystem implementation.
  33. /// This will be available when enumerating the available descriptors at runtime.
  34. /// </summary>
  35. public string id { get; set; }
  36. /// <summary>
  37. /// The <c>Type</c> of the implementation.
  38. /// </summary>
  39. public Type subsystemImplementationType { get; set; }
  40. public override int GetHashCode()
  41. {
  42. unchecked
  43. {
  44. var hash = (id != null) ? id.GetHashCode() : 0;
  45. hash = hash * 486187739 + ((subsystemImplementationType != null) ? subsystemImplementationType.GetHashCode() : 0);
  46. hash = hash * 486187739 + supportsInstall.GetHashCode();
  47. hash = hash * 486187739 + supportsMatchFrameRate.GetHashCode();
  48. return hash;
  49. }
  50. }
  51. public override bool Equals(object obj)
  52. {
  53. if (!(obj is Cinfo))
  54. return false;
  55. return Equals((Cinfo)obj);
  56. }
  57. public bool Equals(Cinfo other)
  58. {
  59. return
  60. string.Equals(id, other.id) &&
  61. (subsystemImplementationType == other.subsystemImplementationType) &&
  62. (supportsInstall == other.supportsInstall) &&
  63. (supportsMatchFrameRate == other.supportsMatchFrameRate);
  64. }
  65. public static bool operator ==(Cinfo lhs, Cinfo rhs)
  66. {
  67. return lhs.Equals(rhs);
  68. }
  69. public static bool operator !=(Cinfo lhs, Cinfo rhs)
  70. {
  71. return !lhs.Equals(rhs);
  72. }
  73. }
  74. /// <summary>
  75. /// Register a subsystem implementation.
  76. /// This should only be used by subsystem implementors.
  77. /// </summary>
  78. /// <param name="cinfo">Information used to construct the descriptor.</param>
  79. public static void RegisterDescriptor(Cinfo cinfo)
  80. {
  81. SubsystemRegistration.CreateDescriptor(new XRSessionSubsystemDescriptor(cinfo));
  82. }
  83. XRSessionSubsystemDescriptor(Cinfo cinfo)
  84. {
  85. id = cinfo.id;
  86. subsystemImplementationType = cinfo.subsystemImplementationType;
  87. supportsInstall = cinfo.supportsInstall;
  88. supportsMatchFrameRate = cinfo.supportsMatchFrameRate;
  89. }
  90. }
  91. }