三国卡牌客户端基础资源仓库
hch
2 天以前 7087e88c414b237cb782bf40da6694c40bddee5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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();
    }
}