69 lines
3.2 KiB
C#
69 lines
3.2 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.SystemEditor
|
|
{
|
|
[CustomEditor(typeof(ShapeDragger))]
|
|
public class ShapeDraggerEditor : Editor
|
|
{
|
|
private SerializedProperty isDraggableProperty;
|
|
private SerializedProperty sortingLayerNameProperty;
|
|
private SerializedProperty dragLayerOrderProperty;
|
|
private SerializedProperty idleLayerOrderProperty;
|
|
private SerializedProperty pressLayerOrderProperty;
|
|
|
|
private SerializedProperty longPressDurationProperty;
|
|
private SerializedProperty longPressScaleProperty;
|
|
private SerializedProperty shakeIntensityProperty;
|
|
|
|
private SerializedProperty dragFollowSpeedProperty;
|
|
|
|
private void OnEnable()
|
|
{
|
|
isDraggableProperty = serializedObject.FindProperty("isDraggable");
|
|
sortingLayerNameProperty = serializedObject.FindProperty("sortingLayerId");
|
|
dragLayerOrderProperty = serializedObject.FindProperty("dragLayerOrder");
|
|
idleLayerOrderProperty = serializedObject.FindProperty("idleLayerOrder");
|
|
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(isDraggableProperty, 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(idleLayerOrderProperty, new GUIContent("闲置时 Order"));
|
|
EditorGUILayout.PropertyField(pressLayerOrderProperty, new GUIContent("长按时 Order"));
|
|
|
|
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();
|
|
}
|
|
}
|
|
} |