三国卡牌客户端基础资源仓库
2个文件已修改
51 ■■■■ 已修改文件
Assets/Editor/ConfigGen/ConfigGenerater.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UI/UIBaseInspector.cs 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ConfigGen/ConfigGenerater.cs
@@ -5,6 +5,7 @@
using System.Text;
using UnityEditor;
using UnityEngine;
using System.Linq;
/// <summary>
/// 配置生成器 - 用于自动生成配置管理器代码
@@ -15,6 +16,18 @@
    private const string ConfigsPath = "Assets/Scripts/Main/Config/Configs";
    private const string ConfigManagerPath = "Assets/Scripts/Main/Manager/ConfigManager.cs";
    
    private static List<string> ExcludeClassList = new List<string>()
    {
        "InitialFunctionConfig",
        "PriorLanguageConfig",
    };
    [MenuItem("Tools/手动刷新")]
    public static void Refresh()
    {
        AssetDatabase.Refresh();
    }
    /// <summary>
    /// 生成配置管理器菜单项
    /// </summary>
@@ -26,6 +39,8 @@
            // 获取所有配置类
            List<string> configClasses = GetAllConfigClasses();
            
            configClasses = new List<string>(configClasses.Where(config => !ExcludeClassList.Contains(config)));
            // 生成配置管理器代码
            GenerateConfigManager(configClasses);
            
Assets/Editor/UI/UIBaseInspector.cs
@@ -1,7 +1,7 @@
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(UIBase))]
[CustomEditor(typeof(UIBase), true)]
public class UIBaseInspector : Editor
{
    SerializedProperty uiLayer;
@@ -10,26 +10,34 @@
    SerializedProperty supportParentChildRelation;
    SerializedProperty isPersistent;
    SerializedProperty maxIdleRounds;
    // 动画相关
    SerializedProperty openAnimationType;
    SerializedProperty closeAnimationType;
    SerializedProperty animationDuration;
    SerializedProperty animeRoot;
    SerializedProperty animeDuration;
    SerializedProperty scaleOverInOutCurve;
    SerializedProperty animationEase;
    SerializedProperty openMask;
    SerializedProperty clickEmptySpaceClose;
    void OnEnable()
    {
        // 获取所有SerializedProperty
        uiLayer = serializedObject.FindProperty("uiLayer");
        uiName = serializedObject.FindProperty("uiName");
        isMainUI = serializedObject.FindProperty("isMainUI");
        supportParentChildRelation = serializedObject.FindProperty("supportParentChildRelation");
        isPersistent = serializedObject.FindProperty("isPersistent");
        maxIdleRounds = serializedObject.FindProperty("maxIdleRounds");
        openAnimationType = serializedObject.FindProperty("openAnimationType");
        closeAnimationType = serializedObject.FindProperty("closeAnimationType");
        animationDuration = serializedObject.FindProperty("animationDuration");
        animeRoot = serializedObject.FindProperty("_rectTransform");
        animeDuration = serializedObject.FindProperty("animeDuration");
        scaleOverInOutCurve = serializedObject.FindProperty("scaleOverInOutCurve");
        animationEase = serializedObject.FindProperty("animationEase");
        openMask = serializedObject.FindProperty("openMask");
        clickEmptySpaceClose = serializedObject.FindProperty("clickEmptySpaceClose");
    }
@@ -57,32 +65,35 @@
        EditorGUILayout.LabelField("动画设置", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(openAnimationType);
        EditorGUILayout.PropertyField(closeAnimationType);
        EditorGUILayout.PropertyField(animeRoot, new GUIContent("animeRoot (动画根节点)"));
        if (openAnimationType.enumValueIndex != 0 || closeAnimationType.enumValueIndex != 0)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(animationDuration);
            EditorGUILayout.PropertyField(animeDuration);
            if ((UIAnimationType)openAnimationType.enumValueIndex == UIAnimationType.ScaleOverInOut)
            {
                EditorGUILayout.PropertyField(scaleOverInOutCurve);
            }
            EditorGUILayout.PropertyField(animationEase);
            EditorGUI.indentLevel--;
        }
        // 动画生效提示
        if ((openAnimationType.enumValueIndex != 0 || closeAnimationType.enumValueIndex != 0) && animeRoot.objectReferenceValue == null)
        {
            EditorGUILayout.HelpBox("如需动画生效,必须指定 animeRoot(动画根节点)!", MessageType.Warning);
        }
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("遮罩设置", EditorStyles.boldLabel);
        // 使用BeginHorizontal来创建一个水平布局组
        EditorGUILayout.BeginHorizontal();
        // 创建一个开关按钮组
        EditorGUI.BeginChangeCheck();
        bool tempOpenMask = GUILayout.Toggle(openMask.boolValue, "开启遮罩", EditorStyles.miniButtonLeft);
        bool tempClickEmptyClose = GUILayout.Toggle(clickEmptySpaceClose.boolValue, "点击空白关闭", EditorStyles.miniButtonRight);
        // 如果有改变
        if (EditorGUI.EndChangeCheck())
        {
            // 确保只有一个可以为true
            if (tempOpenMask && tempClickEmptyClose)
            {
                // 如果两个都为true,保持最后改变的那个为true
                if (openMask.boolValue != tempOpenMask)
                {
                    clickEmptySpaceClose.boolValue = false;
@@ -100,7 +111,6 @@
                clickEmptySpaceClose.boolValue = tempClickEmptyClose;
            }
        }
        EditorGUILayout.EndHorizontal();
        serializedObject.ApplyModifiedProperties();