SpatialSelectableInspector.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using EZXR.Glass.Inputs;
  6. using System;
  7. namespace EZXR.Glass.UI
  8. {
  9. [CustomEditor(typeof(SpatialSelectable))]
  10. [CanEditMultipleObjects]
  11. public class SpatialSelectableInspector : SpatialUIElementInspector
  12. {
  13. private SpatialSelectable _target_SpatialSelectableInspector;
  14. SerializedProperty navigation;
  15. SerializedProperty beFocusedWhenEnabled;
  16. SerializedProperty navigationUp;
  17. SerializedProperty navigationDown;
  18. SerializedProperty navigationLeft;
  19. SerializedProperty navigationRight;
  20. protected void Awake()
  21. {
  22. }
  23. protected override void OnEnable()
  24. {
  25. base.OnEnable();
  26. _target_SpatialSelectableInspector = target as SpatialSelectable;
  27. navigation = serializedObject.FindProperty("navigation");
  28. beFocusedWhenEnabled = serializedObject.FindProperty("beFocusedWhenEnabled");
  29. navigationUp = serializedObject.FindProperty("navigationUp");
  30. navigationDown = serializedObject.FindProperty("navigationDown");
  31. navigationLeft = serializedObject.FindProperty("navigationLeft");
  32. navigationRight = serializedObject.FindProperty("navigationRight");
  33. }
  34. public override void OnInspectorGUI()
  35. {
  36. base.OnInspectorGUI();
  37. serializedObject.Update();
  38. EditorGUILayout.PropertyField(navigation, new GUIContent("启用按键导航"));
  39. if (_target_SpatialSelectableInspector.navigation)
  40. {
  41. EditorGUILayout.PropertyField(beFocusedWhenEnabled, new GUIContent("BeFocusedWhenEnabled", "当此元素出现时将作为当前被选中的元素继续进行导航"));
  42. EditorGUILayout.PropertyField(navigationUp, new GUIContent(" Up"));
  43. EditorGUILayout.PropertyField(navigationDown, new GUIContent(" Down"));
  44. EditorGUILayout.PropertyField(navigationLeft, new GUIContent(" Left"));
  45. EditorGUILayout.PropertyField(navigationRight, new GUIContent(" Right"));
  46. }
  47. serializedObject.ApplyModifiedProperties();
  48. SceneView.RepaintAll();
  49. }
  50. }
  51. }