SpatialUI.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace EZXR.Glass.UI
  4. {
  5. public class SpatialUI : MonoBehaviour
  6. {
  7. //public static void InstantiatePrefab(GameObject prefab)
  8. //{
  9. // bool parentExists = false;
  10. // Transform parent = null;
  11. // Transform subElements = null;
  12. // if (Selection.activeTransform != null)
  13. // {
  14. // parentExists = true;
  15. // parent = Selection.activeTransform;
  16. // }
  17. // GameObject obj = Common.PrefabUtility.InstantiateInstanceWithUndoAndSelection(prefab, parent) as GameObject;
  18. // SpatialUIElement spatialUIElement = obj.GetComponent<SpatialUIElement>();
  19. // if (spatialUIElement != null)
  20. // {
  21. // //所有新创建的UI使用SpatialUIController中设定的unitsPerPixel
  22. // spatialUIElement.curUnitsPerPixel = SpatialUIController.Instance.unitsPerPixel;
  23. // }
  24. // if (parentExists)
  25. // {
  26. // obj.transform.localPosition = Vector3.zero;
  27. // if (parent.GetComponent<SpatialUIElement>() != null)
  28. // {
  29. // //如果在SpatialUIElement物体上右键创建UI的话,会直接创建到子物体SubElements下
  30. // subElements = parent.Find("SubElements");
  31. // if (subElements == null)
  32. // {
  33. // subElements = new GameObject("SubElements").transform;
  34. // subElements.parent = parent;
  35. // subElements.localEulerAngles = Vector3.zero;
  36. // }
  37. // obj.transform.parent = subElements;
  38. // SpatialUIElement spatialUIElement_Parent = parent.GetComponent<SpatialUIElement>();
  39. // //避免子级的SpatialUI显示反向
  40. // obj.transform.localEulerAngles = Vector3.zero;
  41. // if (spatialUIElement != null)
  42. // {
  43. // //避免子级的SpatialUI被父级盖住
  44. // spatialUIElement.sortingOrder = spatialUIElement_Parent.sortingOrder + 1;
  45. // }
  46. // }
  47. // }
  48. //}
  49. //#region SpatialButton
  50. //[MenuItem("GameObject/XR UI(Beta)/Button/Normal", false, 20)]
  51. //public static void AddSpatialButtonNormal()
  52. //{
  53. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialButton(Normal).prefab";
  54. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  55. // {
  56. // filePath = AssetDatabase.GUIDToAssetPath("06c2f8e21ae9b374daebeac328167671");
  57. // }
  58. // InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  59. //}
  60. //[MenuItem("GameObject/XR UI(Beta)/Button/RoundThick", false, 20)]
  61. //public static void AddSpatialButton()
  62. //{
  63. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialButton(RoundThick).prefab";
  64. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  65. // {
  66. // filePath = AssetDatabase.GUIDToAssetPath("bb9542d808f4aa045ad968ed06c6851e");
  67. // }
  68. // InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  69. //}
  70. //#endregion
  71. //#region SpatialImage
  72. //[MenuItem("GameObject/XR UI(Beta)/Image", false, 20)]
  73. //public static void AddSpatialImage()
  74. //{
  75. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialImage.prefab";
  76. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  77. // {
  78. // filePath = AssetDatabase.GUIDToAssetPath("383887ce0ab85e84d9bacacf6f8496f2");
  79. // }
  80. // InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  81. //}
  82. //#endregion
  83. //#region SpatialPanel
  84. //[MenuItem("GameObject/XR UI(Beta)/Panel", false, 20)]
  85. //public static void AddSpatialPanel()
  86. //{
  87. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialPanel.prefab";
  88. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  89. // {
  90. // filePath = AssetDatabase.GUIDToAssetPath("229f883ea3b83b046bcbfa049550b0a8");
  91. // }
  92. // InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  93. //}
  94. //#endregion
  95. //#region SpatialTrigger
  96. //[MenuItem("GameObject/XR UI(Beta)/Trigger", false, 20)]
  97. //public static void AddSpatialTrigger()
  98. //{
  99. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialTrigger.prefab";
  100. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  101. // {
  102. // filePath = AssetDatabase.GUIDToAssetPath("44279d0548e666040a3e3fe81d68bccd");
  103. // }
  104. // InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  105. //}
  106. //#endregion
  107. //#region SpatialUIController
  108. //[MenuItem("GameObject/XR UI(Beta)/UIController", false, 20)]
  109. //public static void AddSpatialUIController()
  110. //{
  111. // if (FindObjectOfType<SpatialUIController>() == null)
  112. // {
  113. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialUIController.prefab";
  114. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  115. // {
  116. // filePath = AssetDatabase.GUIDToAssetPath("13c81cfdca600f04fac9a6a4f117013f");
  117. // }
  118. // Common.PrefabUtility.InstantiatePrefabWithUndoAndSelection(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  119. // }
  120. //}
  121. //#endregion
  122. //#region SpatialUIEventSystem
  123. //[MenuItem("GameObject/XR UI(Beta)/UIEventSystem", false, 20)]
  124. //public static void AddSpatialUIEventSystem()
  125. //{
  126. // if (FindObjectOfType<SpatialUIEventSystem>() == null)
  127. // {
  128. // string filePath = "Assets/EZXRGlassSDK/Core/SpatialUI/Resources/SpatialUIEventSystem.prefab";
  129. // if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
  130. // {
  131. // filePath = AssetDatabase.GUIDToAssetPath("2facc6fb6d026004486467c9b4ef2d63");
  132. // }
  133. // Common.PrefabUtility.InstantiatePrefabWithUndoAndSelection(AssetDatabase.LoadAssetAtPath<GameObject>(filePath));
  134. // }
  135. //}
  136. //#endregion
  137. }
  138. }