SpatialButtonThickInspector.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace EZXR.Glass.UI
  6. {
  7. [CustomEditor(typeof(SpatialButton_Thick))]
  8. [CanEditMultipleObjects]
  9. public class SpatialButtonThickInspector : SpatialButtonInspector
  10. {
  11. SpatialButton_Thick _target_SpatialButton_Thick;
  12. SerializedProperty icon;
  13. SerializedProperty iconSize;
  14. SerializedProperty circleHoverThick;
  15. protected override void OnEnable()
  16. {
  17. base.OnEnable();
  18. _target_SpatialButton_Thick = target as SpatialButton_Thick;
  19. icon = serializedObject.FindProperty("icon");
  20. iconSize = serializedObject.FindProperty("iconSize");
  21. circleHoverThick = serializedObject.FindProperty("circleHoverThick");
  22. }
  23. public override void OnInspectorGUI()
  24. {
  25. base.OnInspectorGUI();
  26. serializedObject.Update();
  27. if (_target_SpatialButton_Thick.size.z <= _target_SpatialButton_Thick.heightMin)
  28. {
  29. _target_SpatialButton_Thick.size = new Vector3(_target_SpatialButton_Thick.size.x, _target_SpatialButton_Thick.size.y, _target_SpatialButton_Thick.heightMin * 2);
  30. }
  31. EditorGUILayout.BeginHorizontal();
  32. {
  33. EditorGUILayout.PropertyField(icon);
  34. if (GUILayout.Button(new GUIContent("Set Physical Size", "按照SpatialUIController.unitsPerPixel中设定的“像素-UnityUnit转换比例”将Icon以换算后的物理尺寸绘制在空间中")))
  35. {
  36. Undo.RecordObject(_target_SpatialButton_Thick, "Set Physical Size");
  37. _target_SpatialButton_Thick.iconSize = new Vector3(_target_SpatialButton_Thick.Icon.width * _target_SpatialButton_Thick.curUnitsPerPixel, _target_SpatialButton_Thick.Icon.height * _target_SpatialButton_Thick.curUnitsPerPixel, _target_SpatialButton_Thick.iconSize.z);
  38. //_target_SpatialButton_Thick.curUnitsPerPixel = SpatialUIController.Instance.unitsPerPixel;
  39. EditorApplication.QueuePlayerLoopUpdate();
  40. }
  41. }
  42. EditorGUILayout.EndHorizontal();
  43. EditorGUILayout.PropertyField(iconSize);
  44. EditorGUILayout.PropertyField(circleHoverThick);
  45. serializedObject.ApplyModifiedProperties();
  46. SceneView.RepaintAll();
  47. }
  48. }
  49. }