123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- using EZXR.Glass.Plane;
- using EZXR.Glass.SixDof;
- #if SpatialComputing
- using EZXR.Glass.SpatialComputing;
- #endif
- #if SpatialMesh
- using EZXR.Glass.SpatialMesh;
- #endif
- #if Tracking2D
- using EZXR.Glass.Tracking2D;
- #endif
- #if Tracking3D
- using EZXR.Glass.Tracking3D;
- #endif
- using EZXR.Glass.Core;
- using UnityEditor;
- using UnityEngine;
- [CustomEditor(typeof(XRMan))]
- [CanEditMultipleObjects]
- public class XRManInspector : Editor
- {
- bool toggle_PlaneDetection = false;
- bool toggle_PlaneDetection_Last = false;
- bool toggle_SpatialMesh = false;
- bool toggle_SpatialMesh_Last = false;
- bool toggle_SpatialComputing = false;
- bool toggle_SpatialComputing_Last = false;
- bool toggle_ImageDetection = false;
- bool toggle_ImageDetection_Last = false;
- bool toggle_ObjectDetection = false;
- bool toggle_ObjectDetection_Last = false;
- XRMan xrMan;
- SerializedProperty m_dof;
- private void OnEnable()
- {
- xrMan = (XRMan)target;
- m_dof = serializedObject.FindProperty("m_dof");
- toggle_PlaneDetection = FindObjectOfType<PlaneDetectionManager>() != null;
- toggle_PlaneDetection_Last = toggle_PlaneDetection;
- #if SpatialMesh
- toggle_SpatialMesh = FindObjectOfType<SpatialMeshManager>() != null;
- toggle_SpatialMesh_Last = toggle_SpatialMesh;
- #endif
- #if SpatialComputing
- toggle_SpatialComputing = FindObjectOfType<EZXRSpatialComputingManager>() != null;
- toggle_SpatialComputing_Last = toggle_SpatialComputing;
- #endif
- #if Tracking2D
- toggle_ImageDetection = FindObjectOfType<Tracking2DManager>() != null;
- toggle_ImageDetection_Last = toggle_ImageDetection;
- #endif
- #if Tracking3D
- toggle_ObjectDetection = FindObjectOfType<Tracking3DManager>() != null;
- toggle_ObjectDetection_Last = toggle_ObjectDetection;
- #endif
- }
- GUIContent content_Dof = new GUIContent("SpatialTracking", "基础组件,不可以被关闭!");
- GUIContent content_InputSystem = new GUIContent("InputSystem", "基础组件,不可以被关闭!");
- GUIContent content_SpatialMesh = new GUIContent("SpatialMesh", "启用后将会开启空间网格生成,有一定的性能开销!");
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- GUIStyle box = GUI.skin.box;
- EditorGUILayout.BeginVertical(box);
- {
- EditorGUILayout.BeginToggleGroup(content_Dof, true);
- {
- EditorGUILayout.PropertyField(m_dof, new GUIContent("DegreeOfFreedom"));
- toggle_SpatialMesh = EditorGUILayout.Toggle(content_SpatialMesh, toggle_SpatialMesh);
- }
- EditorGUILayout.EndToggleGroup();
- }
- EditorGUILayout.EndVertical();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- EditorGUILayout.BeginVertical(box);
- {
- EditorGUILayout.BeginToggleGroup(content_InputSystem, true);
- {
- }
- EditorGUILayout.EndToggleGroup();
- }
- EditorGUILayout.EndVertical();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- #region PlaneDetection
- EditorGUILayout.BeginVertical(box);
- {
- toggle_PlaneDetection = EditorGUILayout.BeginToggleGroup("PlaneDetection", toggle_PlaneDetection);
- if (toggle_PlaneDetection_Last != toggle_PlaneDetection)
- {
- if (toggle_PlaneDetection)
- {
- if (FindObjectOfType<PlaneDetectionManager>() == null)
- {
- string filePath = "Assets/EZXRGlassSDK/Core/SixDof/Prefabs/PlaneDetectionManager.prefab";
- if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
- {
- filePath = AssetDatabase.GUIDToAssetPath("1a44cb9e3dd5f5046a7333d3057af165");
- }
- EZXR.Glass.Core.PrefabUtility.InstantiatePrefabWithUndo(AssetDatabase.LoadAssetAtPath<GameObject>(filePath), xrMan.attachments);
- }
- }
- else
- {
- PlaneDetectionManager planeDetectionManager = FindObjectOfType<PlaneDetectionManager>();
- if (planeDetectionManager != null)
- {
- DestroyImmediate(planeDetectionManager.gameObject);
- }
- }
- }
- toggle_PlaneDetection_Last = toggle_PlaneDetection;
- EditorGUILayout.EndToggleGroup();
- }
- EditorGUILayout.EndVertical();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- #endregion
- #region ImageDetection
- #if Tracking2D
- EditorGUILayout.BeginVertical(box);
- {
- toggle_ImageDetection = EditorGUILayout.BeginToggleGroup("ImageDetection", toggle_ImageDetection);
- if (toggle_ImageDetection_Last != toggle_ImageDetection)
- {
- if (toggle_ImageDetection)
- {
- if (FindObjectOfType<Tracking2DManager>() == null)
- {
- string filePath = "Assets/EZXRGlassSDK/Core/Tracking2D/Prefabs/Tracking2DManager.prefab";
- if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
- {
- filePath = AssetDatabase.GUIDToAssetPath("c1ccc76a41cf54cdfb14a3580ad173f2");
- }
- EZXR.Glass.Core.PrefabUtility.InstantiatePrefabWithUndo(AssetDatabase.LoadAssetAtPath<GameObject>(filePath), xrMan.attachments);
- }
- }
- else
- {
- Tracking2DManager imageDetectionManager = FindObjectOfType<Tracking2DManager>();
- if (imageDetectionManager != null)
- {
- DestroyImmediate(imageDetectionManager.gameObject);
- }
- }
- }
- toggle_ImageDetection_Last = toggle_ImageDetection;
- EditorGUILayout.EndToggleGroup();
- }
- EditorGUILayout.EndVertical();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- #endif
- #endregion
- #region ObjectDetection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- #region SpatialComputing
- #if SpatialComputing
- EditorGUILayout.BeginVertical(box);
- {
- toggle_SpatialComputing = EditorGUILayout.BeginToggleGroup("SpatialComputing", toggle_SpatialComputing);
- if (toggle_SpatialComputing_Last != toggle_SpatialComputing)
- {
- if (toggle_SpatialComputing)
- {
- if (FindObjectOfType<EZXRSpatialComputingManager>() == null)
- {
- string filePath = "Assets/EZXRGlassSDK/Core/SpatialComputing/Prefabs/SpatialComputingManager.prefab";
- if (AssetDatabase.LoadAssetAtPath<GameObject>(filePath) == null)
- {
- filePath = AssetDatabase.GUIDToAssetPath("2ff96ba100da74917a4b639f15c46cae");
- }
- EZXR.Glass.Core.PrefabUtility.InstantiatePrefabWithUndo(AssetDatabase.LoadAssetAtPath<GameObject>(filePath), xrMan.attachments);
- }
- }
- else
- {
- EZXRSpatialComputingManager spatialComputingManager = FindObjectOfType<EZXRSpatialComputingManager>();
- if (spatialComputingManager != null)
- {
- DestroyImmediate(spatialComputingManager.gameObject);
- }
- }
- }
- toggle_SpatialComputing_Last = toggle_SpatialComputing;
- EditorGUILayout.EndToggleGroup();
- }
- EditorGUILayout.EndVertical();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- #endif
- #endregion
- serializedObject.ApplyModifiedProperties();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|