三国卡牌客户端基础资源仓库
693bcf47303fbb1e1a10e9702debdb387ef97f86..5287d0b403ca849fe7e559f95b0a8aab09689468
2025-06-10 hch
0312 版本号统一显示格式
5287d0 对比 | 目录
2025-06-10 yyl
18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建 新增SortingLayer UI, UI调试器
c2ea7f 对比 | 目录
5个文件已修改
2个文件已添加
163 ■■■■■ 已修改文件
Assets/Editor/Tool/PrefabCreateTool.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UI/UIAdjustEditor.cs 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UI/UIAdjustEditor.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UIPattern/CommonButton.prefab 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/UI/LaunchWins/LaunchExWin.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Resources/Prefabs/ScreenMask.prefab 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ProjectSettings/TagManager.asset 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/PrefabCreateTool.cs
@@ -134,7 +134,11 @@
    public static void CreateTextEx()
    {
        var instance = new GameObject("TextEx");
        instance.AddComponent<TextEx>();
        var text = instance.AddComponent<TextEx>();
        text.font = FontUtility.preferred;
        text.fontSize = 22;
        text.alignment = TextAnchor.MiddleCenter;
        text.raycastTarget = false;
        SetParent(instance);
    }
@@ -142,7 +146,8 @@
    public static void CreateImageEx()
    {
        var instance = new GameObject("ImageEx");
        instance.AddComponent<ImageEx>();
        var image = instance.AddComponent<ImageEx>();
        image.raycastTarget = false;
        SetParent(instance);
    }
Assets/Editor/UI/UIAdjustEditor.cs
New file
@@ -0,0 +1,119 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class UIAdjustEditor : EditorWindow
{
    private string uiName = "";
    private bool destroyOnClose = false;
    private Vector2 scrollPos;
    [MenuItem("Tools/UI 调试工具")]
    public static void ShowWindow()
    {
        GetWindow<UIAdjustEditor>("UI 调试工具");
    }
    void OnGUI()
    {
        EditorGUILayout.LabelField("UI 调试工具", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        uiName = EditorGUILayout.TextField("界面名字", uiName);
        destroyOnClose = EditorGUILayout.Toggle("关闭时销毁", destroyOnClose);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("打开 UI"))
        {
            if (Application.isPlaying && !string.IsNullOrEmpty(uiName))
            {
                UIManager.Instance.OpenWindow(uiName);
            }
            else
            {
                Debug.LogWarning("请在运行时操作,并输入界面名字。");
            }
        }
        if (GUILayout.Button("关闭 UI"))
        {
            if (Application.isPlaying && !string.IsNullOrEmpty(uiName))
            {
                UIManager.Instance.CloseWindow(uiName, destroyOnClose);
            }
            else
            {
                Debug.LogWarning("请在运行时操作,并输入界面名字。");
            }
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("当前已打开的界面:", EditorStyles.boldLabel);
        if (Application.isPlaying)
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(200));
            var dict = GetOpenUIDict();
            if (dict.Count == 0)
            {
                EditorGUILayout.LabelField("无已打开的界面");
            }
            else
            {
                foreach (var kv in dict)
                {
                    EditorGUILayout.BeginHorizontal();
                    // 名字做成按钮
                    if (GUILayout.Button($"{kv.Key}  (数量: {kv.Value})", GUILayout.Width(200)))
                    {
                        // 通过反射获取UI GameObject
                        var mgr = UIManager.Instance;
                        var field = typeof(UIManager).GetField("uiDict", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                        if (field != null)
                        {
                            var uiDict = field.GetValue(mgr) as Dictionary<string, List<UIBase>>;
                            if (uiDict != null && uiDict.TryGetValue(kv.Key, out var list) && list != null && list.Count > 0)
                            {
                                var ui = list[0];
                                if (ui != null && ui.gameObject != null)
                                {
                                    Selection.activeObject = ui.gameObject;
                                    EditorGUIUtility.PingObject(ui.gameObject);
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        else
        {
            EditorGUILayout.HelpBox("请在运行时查看已打开的界面。", MessageType.Info);
        }
    }
    /// <summary>
    /// 获取当前已打开的UI名称及数量
    /// </summary>
    private Dictionary<string, int> GetOpenUIDict()
    {
        var result = new Dictionary<string, int>();
        var mgr = UIManager.Instance;
        var field = typeof(UIManager).GetField("uiDict", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        if (field != null)
        {
            var dict = field.GetValue(mgr) as Dictionary<string, List<UIBase>>;
            if (dict != null)
            {
                foreach (var kv in dict)
                {
                    if (kv.Value != null && kv.Value.Count > 0)
                        result[kv.Key] = kv.Value.Count;
                }
            }
        }
        return result;
    }
}
Assets/Editor/UI/UIAdjustEditor.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90660ccae9cbfef40acbd5fac20c0734
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Editor/UIPattern/CommonButton.prefab
@@ -29,10 +29,10 @@
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children:
  - {fileID: 8818173244328049919}
  m_Father: {fileID: 0}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0.5, y: 0.5}
  m_AnchorMax: {x: 0.5, y: 0.5}
@@ -53,6 +53,7 @@
  m_EditorClassIdentifier: 
  m_Navigation:
    m_Mode: 3
    m_WrapAround: 0
    m_SelectOnUp: {fileID: 0}
    m_SelectOnDown: {fileID: 0}
    m_SelectOnLeft: {fileID: 0}
@@ -110,6 +111,7 @@
  m_Material: {fileID: 0}
  m_Color: {r: 1, g: 1, b: 1, a: 1}
  m_RaycastTarget: 1
  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
  m_Maskable: 1
  m_OnCullStateChanged:
    m_PersistentCalls:
@@ -154,14 +156,14 @@
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 6799213541382060757}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0.5, y: 0.5}
  m_AnchorMax: {x: 0.5, y: 0.5}
  m_AnchoredPosition: {x: 0, y: 0}
  m_SizeDelta: {x: 144.9, y: 39.02}
  m_SizeDelta: {x: 148, y: 50}
  m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3214953141854913601
CanvasRenderer:
@@ -185,7 +187,8 @@
  m_EditorClassIdentifier: 
  m_Material: {fileID: 0}
  m_Color: {r: 0.2509804, g: 0.10980392, b: 0.023529412, a: 1}
  m_RaycastTarget: 1
  m_RaycastTarget: 0
  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
  m_Maskable: 1
  m_OnCullStateChanged:
    m_PersistentCalls:
@@ -194,7 +197,7 @@
    m_Font: {fileID: 12800000, guid: 7cd825c6867461a4090871836190730f, type: 3}
    m_FontSize: 30
    m_FontStyle: 0
    m_BestFit: 1
    m_BestFit: 0
    m_MinSize: 2
    m_MaxSize: 30
    m_Alignment: 4
@@ -207,3 +210,4 @@
  m_IsKey: 0
  m_KeyName: 
  m_ColorType: 7
  m_BGColorType: 0
Assets/Launch/UI/LaunchWins/LaunchExWin.cs
@@ -63,7 +63,10 @@
        {
            m_AndroidProgressContainer.gameObject.SetActive(true);
            m_IosProgressContainer.gameObject.SetActive(false);
            m_Version.text = StringUtility.Contact(VersionConfigEx.Get().version, "_", VersionConfigEx.Get().buildIndex, LocalResManager.Id);
            //打包版本 + 功能版本 + 语言ID
            m_Version.text = StringUtility.Contact(VersionConfigEx.Get().version, "_", VersionConfigEx.Get().buildIndex,
                "_", InitialFunctionConfig.Get("version").Numerical1, " ", LocalResManager.Id);
        }
Assets/Resources/Prefabs/ScreenMask.prefab
@@ -35,7 +35,7 @@
  m_AnchorMin: {x: 0.5, y: 0.5}
  m_AnchorMax: {x: 0.5, y: 0.5}
  m_AnchoredPosition: {x: 0, y: 0}
  m_SizeDelta: {x: 15000, y: 26680}
  m_SizeDelta: {x: 2000, y: 4000}
  m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5139521211198942054
CanvasRenderer:
ProjectSettings/TagManager.asset
@@ -41,3 +41,6 @@
  - name: Default
    uniqueID: 0
    locked: 0
  - name: UI
    uniqueID: 36244067
    locked: 0