From ea095835ce08ea8bf716be135fd1af000c96b198 Mon Sep 17 00:00:00 2001 From: m0_75251201 Date: Mon, 14 Jul 2025 19:40:11 +0800 Subject: [PATCH] =?UTF-8?q?(client)=20feat:=E6=B7=BB=E5=8A=A0=E9=94=AE?= =?UTF-8?q?=E5=80=BC=E5=AF=B9=E5=BC=8F=E5=8A=A0=E8=BD=BD=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Scripts/Configs/ConfigProcessor.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Client/Assets/Scripts/Configs/ConfigProcessor.cs b/Client/Assets/Scripts/Configs/ConfigProcessor.cs index 774dfea..6df16ac 100644 --- a/Client/Assets/Scripts/Configs/ConfigProcessor.cs +++ b/Client/Assets/Scripts/Configs/ConfigProcessor.cs @@ -258,5 +258,31 @@ namespace Configs return result; } + /// + /// 用于加载指定路径下的所有资源,并返回资源名称和加载好的资源的键值对。 + /// + /// 资源类型 + /// 资源路径(相对于 Resources 文件夹) + /// 字典,键为资源名称,值为加载好的资源 + public static Dictionary LoadResources(string path) where T : UnityEngine.Object + { + // 创建一个字典来存储资源名称和加载好的资源 + Dictionary resourceDict = new Dictionary(); + + // 加载指定路径下的所有资源 + T[] resources = Resources.LoadAll(path); + + foreach (T resource in resources) + { + if (resource != null) + { + // 获取资源名称并存入字典 + string resourceName = resource.name; + resourceDict[resourceName] = resource; + } + } + + return resourceDict; + } } } \ No newline at end of file