yyl
2026-03-04 bc1cb6da854cb2e9144f10ed55330a537ecdca16
Main/Component/UI/Common/WindowConfig.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using System;
using Cysharp.Threading.Tasks;
[CreateAssetMenu(menuName = "Config/WindowConfig")]
public class WindowConfig : ScriptableObject
@@ -12,11 +13,11 @@
    [NonSerialized] public List<string> childWindows = new List<string>();
    static WindowConfig config;
    static WindowConfig Get()
    public static async UniTask<WindowConfig> Get()
    {
        if (config == null)
        {
            config = BuiltInLoader.LoadScriptableObject<WindowConfig>("WindowConfig");
            config = await BuiltInLoader.LoadScriptableObjectAsync<WindowConfig>("WindowConfig");
            foreach (var table in config.windows)
            {
                var children = config.parentChildrenTable[table.parent] = new List<string>();
@@ -24,12 +25,11 @@
                {
                    children.Add(info.window);
                }
                config.childWindows.AddRange(children);
            }
        }
        return config;
    }
    public static void Release()
@@ -37,29 +37,28 @@
        config = null;
    }
    public static bool FindParentWindow(string child, out string parent)
    public static async UniTask<(bool found, string parent)> FindParentWindow(string child)
    {
        foreach (var table in Get().windows)
        var cfg = await Get();
        foreach (var table in cfg.windows)
        {
            foreach (var orderTable in table.orderTables)
            {
                if (orderTable.window == child)
                {
                    parent = table.parent;
                    return true;
                    return (true, table.parent);
                }
            }
        }
        parent = string.Empty;
        return false;
        return (false, string.Empty);
    }
    public static List<string> GetChildWindows(string parent)
    public static async UniTask<List<string>> GetChildWindows(string parent)
    {
        if (Get().parentChildrenTable.ContainsKey(parent))
        var cfg = await Get();
        if (cfg.parentChildrenTable.ContainsKey(parent))
        {
            return Get().parentChildrenTable[parent];
            return cfg.parentChildrenTable[parent];
        }
        else
        {
@@ -67,73 +66,74 @@
        }
    }
    public static bool IsParentWindow(string name)
    public static async UniTask<bool> IsParentWindow(string name)
    {
        foreach (var window in Get().windows)
        var cfg = await Get();
        foreach (var window in cfg.windows)
        {
            if (window.parent == name)
            {
                return true;
            }
        }
        return false;
    }
    public static bool IsChildWindow(string name)
    public static async UniTask<bool> IsChildWindow(string name)
    {
        return Get().childWindows.Contains(name);
        var cfg = await Get();
        return cfg.childWindows.Contains(name);
    }
    public static WindowLevel GetWindowLevel(string name)
    public static async UniTask<WindowLevel> GetWindowLevel(string name)
    {
        foreach (var window in Get().windows)
        var cfg = await Get();
        foreach (var window in cfg.windows)
        {
            if (window.parent == name)
            {
                return window.level;
            }
        }
        return WindowLevel.None;
    }
    public static string GetWindowPattern(string name)
    public static async UniTask<string> GetWindowPattern(string name)
    {
        foreach (var window in Get().windows)
        var cfg = await Get();
        foreach (var window in cfg.windows)
        {
            if (window.parent == name)
            {
                return window.pattern;
            }
        }
        return string.Empty;
    }
    public static List<OrderTable> GetWindowFunctionInfos(string parent)
    public static async UniTask<List<OrderTable>> GetWindowFunctionInfos(string parent)
    {
        foreach (var table in Get().windows)
        var cfg = await Get();
        foreach (var table in cfg.windows)
        {
            if (table.parent == parent)
            {
                return new List<OrderTable>(table.orderTables);
            }
        }
        return null;
    }
    public static string GetTitleIconKey(string name)
    public static async UniTask<string> GetTitleIconKey(string name)
    {
        foreach (var window in Get().windows)
        var cfg = await Get();
        foreach (var window in cfg.windows)
        {
            if (window.parent == name)
            {
                return window.titleIconKey;
            }
        }
        return string.Empty;
    }