yyl
2025-06-12 5ca88372febc0ebab5cbdb5f922c59a646b8fb94
Main/Manager/UIManager.cs
@@ -225,6 +225,26 @@
        return null;
    }
    public UIBase GetUI(string uiName)
    {
        if (string.IsNullOrEmpty(uiName))
        {
            // 记录错误日志
            Debug.LogError("UI名称为空");
            return null;
        }
        // 尝试从字典中获取UI实例列表
        if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
        {
            // 返回第一个实例
            return uiList[0];
        }
        // 如果不存在,返回null
        return null;
    }
    public List<T> GetUIList<T>() where T : UIBase
    {
        List<T> uiList = new List<T>();
@@ -583,14 +603,12 @@
        return target;
    }
    public UIBase OpenWindow(string uiName)
    public UIBase OpenWindow(string uiName, int functionOrder = 0)
    {
        // 优先从closedUIDict中获取
        UIBase parentUI = null;
        UIBase returnValue = null;
        Debug.Log("OpenWindow " + uiName);
        List<UIBase> closedUIList = new List<UIBase>();
@@ -664,6 +682,7 @@
        UpdateUISortingOrder();
        
        // 打开UI
        returnValue.functionOrder = functionOrder;
        returnValue.HandleOpen();
        OnOpenWindow?.Invoke(returnValue);
@@ -677,11 +696,11 @@
    /// <summary>
    /// 打开UI
    /// </summary>
    public T OpenWindow<T>() where T : UIBase
    public T OpenWindow<T>(int functionOrder = 0) where T : UIBase
    {
        // 获取UI类型名称
        string uiName = typeof(T).Name;
        return OpenWindow(uiName) as T;
        return OpenWindow(uiName, functionOrder) as T;
    }
    
    /// <summary>