46 lines
1.9 KiB
C#
46 lines
1.9 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.SystemEditor
|
|
{
|
|
[CustomEditor(typeof(ShapeDragger))]
|
|
public class ShapeDraggerEditor : Editor
|
|
{
|
|
private SerializedProperty isDraggableProperty;
|
|
private SerializedProperty dragLayerNameProperty;
|
|
private SerializedProperty dragLayerOrderProperty;
|
|
private SerializedProperty idleLayerNameProperty;
|
|
private SerializedProperty idleLayerOrderProperty;
|
|
|
|
private void OnEnable()
|
|
{
|
|
isDraggableProperty = serializedObject.FindProperty("isDraggable");
|
|
dragLayerNameProperty = serializedObject.FindProperty("dragLayerId");
|
|
dragLayerOrderProperty = serializedObject.FindProperty("dragLayerOrder");
|
|
idleLayerNameProperty = serializedObject.FindProperty("idleLayerId");
|
|
idleLayerOrderProperty = serializedObject.FindProperty("idleLayerOrder");
|
|
}
|
|
|
|
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("拖拽时 Layer"), dragLayerNameProperty);
|
|
// 使用 SerializedProperty 绘制 SortingOrder
|
|
EditorGUILayout.PropertyField(dragLayerOrderProperty, new GUIContent("拖拽时 Order"));
|
|
|
|
EditorKit.SortingLayerField(new GUIContent("闲置时 Layer"), idleLayerNameProperty);
|
|
EditorGUILayout.PropertyField(idleLayerOrderProperty, new GUIContent("闲置时 Order"));
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
} |