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.

112 lines
4.1 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// Represents an entry in an <see cref="XRReferenceImageLibrary"/>.
  6. /// </summary>
  7. /// <remarks>
  8. /// A reference image is an image to look for in the physical environment.
  9. /// The <see cref="XRReferenceImage"/> does not directly reference a <c>Texture2D</c>
  10. /// or other image data; it only stores the GUID of the <c>Texture2D</c> as it
  11. /// appears in the <c>AssetDatabase</c>. At build time, platform specific build steps
  12. /// may use the guids to look up the source textures and generate an appropriate
  13. /// image database. At runtime, detected images can be matched up with the source
  14. /// <see cref="XRReferenceImage"/>.
  15. /// </remarks>
  16. [Serializable]
  17. public struct XRReferenceImage : IEquatable<XRReferenceImage>
  18. {
  19. public XRReferenceImage(
  20. SerializableGuid guid, SerializableGuid textureGuid,
  21. Vector2? size, string name, Texture2D texture)
  22. {
  23. m_SerializedGuid = guid;
  24. m_SerializedTextureGuid = textureGuid;
  25. m_SpecifySize = size.HasValue;
  26. m_Size = size.HasValue ? size.Value : Vector2.zero;
  27. m_Name = name;
  28. m_Texture = texture;
  29. }
  30. /// <summary>
  31. /// The <c>Guid</c> associated with this image.
  32. /// </summary>
  33. public Guid guid => m_SerializedGuid.guid;
  34. /// <summary>
  35. /// The <c>Guid</c> of the source texture as it appeared in the
  36. /// [AssetDatabase](https://docs.unity3d.com/ScriptReference/AssetDatabase.html)
  37. /// in the Editor.
  38. /// </summary>
  39. public Guid textureGuid => m_SerializedTextureGuid.guid;
  40. /// <summary>
  41. /// Must be set to true for <see cref="size"/> to be used.
  42. /// </summary>
  43. public bool specifySize => m_SpecifySize;
  44. /// <summary>
  45. /// The size of the image, in meters. This can improve image detection,
  46. /// and may be required by some platforms.
  47. /// </summary>
  48. public Vector2 size => m_Size;
  49. /// <summary>
  50. /// The width of the image, in meters.
  51. /// </summary>
  52. public float width => m_Size.x;
  53. /// <summary>
  54. /// The height of the image, in meters.
  55. /// </summary>
  56. public float height => m_Size.y;
  57. /// <summary>
  58. /// A name associated with this reference image.
  59. /// </summary>
  60. public string name => m_Name;
  61. /// <summary>
  62. /// The source texture which this reference image represents.
  63. /// This may be <c>null</c> to avoid including the texture in
  64. /// the Player build if that is not desired. See
  65. /// <c>UnityEditor.XR.ARSubsystems.XRReferenceImageLibraryExtensions.SetTexture</c>
  66. /// for more details.
  67. /// </summary>
  68. public Texture2D texture => m_Texture;
  69. /// <summary>
  70. /// Provides a string representation suitable for debug logging.
  71. /// </summary>
  72. /// <returns>A string representation of the reference image.</returns>
  73. public override string ToString() =>
  74. $"GUID: '{guid}', Texture GUID: '{textureGuid}` Size: {(m_SpecifySize ? "" : "NOT ")} specified {m_Size}";
  75. public override int GetHashCode() => guid.GetHashCode();
  76. public override bool Equals(object obj) => (obj is XRReferenceImage) && Equals((XRReferenceImage)obj);
  77. public bool Equals(XRReferenceImage other) => guid.Equals(other.guid);
  78. public static bool operator ==(XRReferenceImage lhs, XRReferenceImage rhs) => lhs.Equals(rhs);
  79. public static bool operator !=(XRReferenceImage lhs, XRReferenceImage rhs) => !lhs.Equals(rhs);
  80. #pragma warning disable CS0649
  81. [SerializeField]
  82. internal SerializableGuid m_SerializedGuid;
  83. [SerializeField]
  84. internal SerializableGuid m_SerializedTextureGuid;
  85. [SerializeField]
  86. internal Vector2 m_Size;
  87. [SerializeField]
  88. internal bool m_SpecifySize;
  89. [SerializeField]
  90. internal string m_Name;
  91. [SerializeField]
  92. internal Texture2D m_Texture;
  93. #pragma warning restore CS0649
  94. }
  95. }