三国卡牌客户端基础资源仓库
hch
3 天以前 7087e88c414b237cb782bf40da6694c40bddee5b
197 子 【内政】淘金系统 / 【内政】淘金系统-客户端
2个文件已添加
115 ■■■■■ 已修改文件
Assets/Editor/ScriptEditor/GoldRushPosEventEditor.cs 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/GoldRushPosEventEditor.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/GoldRushPosEventEditor.cs
New file
@@ -0,0 +1,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();
    }
}
Assets/Editor/ScriptEditor/GoldRushPosEventEditor.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e841718dc01f644db49b0474e02c1fc
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant: