using UnityEditor; using UnityEngine; namespace AibisDream.SystemEditor { [CustomEditor(typeof(ShapeDragger))] public class ShapeDraggerEditor : Editor { private SerializedProperty isInteractableProperty; private SerializedProperty interactionModeProperty; private SerializedProperty sortingLayerNameProperty; private SerializedProperty dragLayerOrderProperty; private SerializedProperty pressLayerOrderProperty; private SerializedProperty longPressDurationProperty; private SerializedProperty longPressScaleProperty; private SerializedProperty shakeIntensityProperty; private SerializedProperty dragFollowSpeedProperty; private void OnEnable() { isInteractableProperty = serializedObject.FindProperty("isInteractable"); interactionModeProperty = serializedObject.FindProperty("interactionMode"); sortingLayerNameProperty = serializedObject.FindProperty("sortingLayerId"); dragLayerOrderProperty = serializedObject.FindProperty("dragLayerOrder"); pressLayerOrderProperty = serializedObject.FindProperty("pressLayerOrder"); longPressDurationProperty = serializedObject.FindProperty("longPressDuration"); longPressScaleProperty = serializedObject.FindProperty("longPressScale"); shakeIntensityProperty = serializedObject.FindProperty("shakeIntensity"); dragFollowSpeedProperty = serializedObject.FindProperty("dragFollowSpeed"); } public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.LabelField("拖拽设置", EditorStyles.boldLabel); EditorGUILayout.PropertyField(isInteractableProperty, new GUIContent("是否可交互")); EditorGUILayout.PropertyField(interactionModeProperty, new GUIContent("交互模式")); EditorGUILayout.Space(); EditorGUILayout.LabelField("排序层设置", EditorStyles.boldLabel); // 使用 EditorKit 的公共函数绘制 SortingLayer EditorKit.SortingLayerField(new GUIContent("Sorting Layer"), sortingLayerNameProperty); // 使用 SerializedProperty 绘制 SortingOrder EditorGUILayout.PropertyField(dragLayerOrderProperty, new GUIContent("拖拽时 Order")); EditorGUILayout.PropertyField(pressLayerOrderProperty, new GUIContent("点击高亮时 Order")); EditorGUILayout.HelpBox("闲置时 Order 取自 Visual 子物体的 SortingGroup,请在 BlockShape 的 Visual Prefab 中配置。", MessageType.Info); EditorGUILayout.Space(); EditorGUILayout.LabelField("长按设置", EditorStyles.boldLabel); EditorGUILayout.PropertyField(longPressDurationProperty, new GUIContent("长按时长")); EditorGUILayout.PropertyField(longPressScaleProperty, new GUIContent("长按放大倍数")); EditorGUILayout.PropertyField(shakeIntensityProperty, new GUIContent("抖动强度")); EditorGUILayout.Space(); EditorGUILayout.LabelField("拖拽跟随", EditorStyles.boldLabel); EditorGUILayout.PropertyField(dragFollowSpeedProperty, new GUIContent("跟随速度", "越大跟得越紧,越小滞后越明显")); serializedObject.ApplyModifiedProperties(); } } }