yyl
2025-05-20 b54023f3a378e71a0e890cc6fafd7f4504037837
ui开关与否的接口支持
1个文件已修改
52 ■■■■■ 已修改文件
Main/UI/UIManager.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/UI/UIManager.cs
@@ -242,6 +242,52 @@
        return null;
    }
    
    public List<T> GetUIList<T>() where T : UIBase
    {
        List<T> uiList = new List<T>();
        // 获取UI类型名称
        string uiName = typeof(T).Name;
        if (string.IsNullOrEmpty(uiName))
        {
            // 记录错误日志
            Debug.LogError("UI名称为空");
            return uiList;
        }
        // 尝试从字典中获取UI实例列表
        uiDict.TryGetValue(uiName, out uiList);
        return uiList;
    }
    public bool IsOpenedInList<T>() where T : UIBase
    {
        List<T> uiList = GetUIList<T>();
        foreach (T ui in uiList)
        {
            if (ui.IsActive())
            {
                return true;
            }
        }
        return false;
    }
    public bool IsOpened<T>() where T : UIBase
    {
        T ui = GetUI<T>();
        if (null != ui)
        {
            return ui.IsActive();
        }
        return false;
    }
    // 获取指定类型的所有UI实例
    public List<T> GetAllUI<T>() where T : UIBase
    {
@@ -538,6 +584,12 @@
        // 获取UI类型名称
        string uiName = typeof(T).Name;
        
        CloseWindow(uiName);
    }
    public void CloseWindow(string uiName)
    {
        // 检查UI是否存在
        if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
        {