NRSerializedImageTarget.cs 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal.NREditor
  10. {
  11. using System.Collections.Generic;
  12. using UnityEngine;
  13. using UnityEditor;
  14. /// <summary> A nr serialized image target. </summary>
  15. public class NRSerializedImageTarget : NRSerializedTrackable
  16. {
  17. /// <summary> The aspect ratio. </summary>
  18. private readonly SerializedProperty m_AspectRatio;
  19. /// <summary> The width. </summary>
  20. private readonly SerializedProperty m_Width;
  21. /// <summary> The height. </summary>
  22. private readonly SerializedProperty m_Height;
  23. /// <summary> The tracking image database. </summary>
  24. private readonly SerializedProperty m_TrackingImageDatabase;
  25. /// <summary> Zero-based index of the database. </summary>
  26. private readonly SerializedProperty m_DatabaseIndex;
  27. /// <summary> Gets the aspect ratio property. </summary>
  28. /// <value> The aspect ratio property. </value>
  29. public SerializedProperty AspectRatioProperty { get { return m_AspectRatio; } }
  30. /// <summary> Gets or sets the aspect ratio. </summary>
  31. /// <value> The aspect ratio. </value>
  32. public float AspectRatio { get { return m_AspectRatio.floatValue; } set { m_AspectRatio.floatValue = value; } }
  33. /// <summary> Gets the width property. </summary>
  34. /// <value> The width property. </value>
  35. public SerializedProperty WidthProperty { get { return m_Width; } }
  36. /// <summary> Gets or sets the width. </summary>
  37. /// <value> The width. </value>
  38. public float Width { get { return m_Width.floatValue; } set { m_Width.floatValue = value; } }
  39. /// <summary> Gets the height property. </summary>
  40. /// <value> The height property. </value>
  41. public SerializedProperty HeightProperty { get { return m_Height; } }
  42. /// <summary> Gets or sets the height. </summary>
  43. /// <value> The height. </value>
  44. public float Height { get { return m_Height.floatValue; } set { m_Height.floatValue = value; } }
  45. /// <summary> Gets the tracking image database property. </summary>
  46. /// <value> The tracking image database property. </value>
  47. public SerializedProperty TrackingImageDatabaseProperty { get { return m_TrackingImageDatabase; } }
  48. /// <summary> Gets or sets the tracking image database. </summary>
  49. /// <value> The tracking image database. </value>
  50. public string TrackingImageDatabase { get { return m_TrackingImageDatabase.stringValue; } set { m_TrackingImageDatabase.stringValue = value; } }
  51. /// <summary> Gets the database index property. </summary>
  52. /// <value> The database index property. </value>
  53. public SerializedProperty DatabaseIndexProperty { get { return m_DatabaseIndex; } }
  54. /// <summary> Gets or sets the zero-based index of the database. </summary>
  55. /// <value> The database index. </value>
  56. public int DatabaseIndex { get { return m_DatabaseIndex.intValue; } set { m_DatabaseIndex.intValue = value; } }
  57. /// <summary> Constructor. </summary>
  58. /// <param name="target"> Target for the.</param>
  59. public NRSerializedImageTarget(SerializedObject target) : base(target)
  60. {
  61. m_AspectRatio = target.FindProperty("m_AspectRatio");
  62. m_Width = target.FindProperty("m_Width");
  63. m_Height = target.FindProperty("m_Height");
  64. m_DatabaseIndex = target.FindProperty("m_DatabaseIndex");
  65. }
  66. /// <summary> Gets the behaviours. </summary>
  67. /// <returns> The behaviours. </returns>
  68. public List<NRTrackableImageBehaviour> GetBehaviours()
  69. {
  70. List<NRTrackableImageBehaviour> list = new List<NRTrackableImageBehaviour>();
  71. Object[] targetObjs = m_SerializedObject.targetObjects;
  72. for (int i = 0; i < targetObjs.Length; i++)
  73. {
  74. list.Add((NRTrackableImageBehaviour)targetObjs[i]);
  75. }
  76. return list;
  77. }
  78. }
  79. }