using UnityEditor;
|
using UnityEngine;
|
|
[CustomEditor(typeof(GoldRushPosEvent))]
|
public class GoldRushPosEventEditor : Editor
|
{
|
SerializedProperty m_PosEvent = null;
|
SerializedProperty m_EaseType;
|
SerializedProperty m_Speed;
|
SerializedProperty m_BackSlowSpeedScale;
|
SerializedProperty m_IsRandom;
|
SerializedProperty m_Value1;
|
SerializedProperty m_Value2;
|
SerializedProperty m_Text1;
|
|
protected void Init()
|
{
|
if (m_PosEvent != null)
|
{
|
return;
|
}
|
m_PosEvent = serializedObject.FindProperty("m_PosEvent");
|
m_EaseType = serializedObject.FindProperty("m_EaseType");
|
m_Speed = serializedObject.FindProperty("m_Speed");
|
m_BackSlowSpeedScale = serializedObject.FindProperty("m_BackSlowSpeedScale");
|
m_IsRandom = serializedObject.FindProperty("m_IsRandom");
|
m_Value1 = serializedObject.FindProperty("m_Value1");
|
m_Value2 = serializedObject.FindProperty("m_Value2");
|
m_Text1 = serializedObject.FindProperty("m_Text1");
|
}
|
|
public override void OnInspectorGUI()
|
{
|
GoldRushPosEvent script = (GoldRushPosEvent)target;
|
|
// 绘制默认的 posEvent 字段
|
Init();
|
|
EditorGUILayout.PropertyField(m_PosEvent, new GUIContent("移动事件"));
|
EditorGUILayout.PropertyField(m_EaseType, new GUIContent("EaseType 移动方式"));
|
EditorGUILayout.PropertyField(m_Speed, new GUIContent("移动速度"));
|
EditorGUILayout.PropertyField(m_BackSlowSpeedScale, new GUIContent("返程速率*移动速度"));
|
// 根据 posEvent 的值动态修改 Header 文字
|
switch (script.m_PosEvent)
|
{
|
case PosEvent.Move:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("是否随机目的地范围"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("x范围"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("y范围"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("无效"));
|
break;
|
case PosEvent.Rush:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("是否随机目的地范围"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("x范围"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("y范围"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("无效"));
|
break;
|
case PosEvent.Jump:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("跳跃高度"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("跳跃时间"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("无效"));
|
break;
|
case PosEvent.Word:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("是否随机文字"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("随机最小"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("随机最大"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("指定语言表"));
|
break;
|
case PosEvent.TargetWord:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("是否随机文字"));
|
if (script.m_IsRandom)
|
{
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("随机最小"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("随机最大"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("指定语言表"));
|
}
|
else
|
{
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("指定第几个工人"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("指定语言表"));
|
}
|
break;
|
case PosEvent.TargetFollow:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("无效"));
|
break;
|
case PosEvent.Action:
|
case PosEvent.TargetAction:
|
EditorGUILayout.PropertyField(m_IsRandom, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Value1, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Value2, new GUIContent("无效"));
|
EditorGUILayout.PropertyField(m_Text1, new GUIContent("动作名"));
|
break;
|
}
|
|
|
// 应用修改
|
serializedObject.ApplyModifiedProperties();
|
}
|
}
|