From d18d4a9dacd9557f2bc0b4cf141e99374406b4dc Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 30 五月 2025 11:39:49 +0800
Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建

---
 Main/Manager/ResManager.cs |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/Main/Manager/ResManager.cs b/Main/Manager/ResManager.cs
index 4fc65df..03e49f3 100644
--- a/Main/Manager/ResManager.cs
+++ b/Main/Manager/ResManager.cs
@@ -98,13 +98,51 @@
         }
     }
 
+#if UNITY_EDITOR
+    public string GetFullDirectory(string directory)
+    {
+        string fullDirectory = Path.Combine(ResourcesOutPath, directory);
+        return fullDirectory;
+    }
+
+    public string FindFilePath(string directory, string fileName)
+    {
+        string[] files = Directory.GetFiles(GetFullDirectory(directory), fileName, SearchOption.AllDirectories);
+        if (files.Length > 0)
+        {
+            return files[0];
+        }
+        return string.Empty;
+    }
+
+    public string GetRelativePath(string absolutePath)
+    {
+        string relativePath = absolutePath.Replace(ResourcesOutPath, "Assets/ResourcesOut/");
+        return relativePath;
+    }
+#endif
+
     public T LoadAsset<T> (string directory, string name) where T : UnityEngine.Object
     {
         T asset = null;
 #if UNITY_EDITOR
         var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T)));
+
+        //  鎵句笉鍒版枃浠舵椂锛屽皾璇曞湪鍐呴儴缁х画鎵�
+        if (!File.Exists(path))
+        {
+            path = GetRelativePath(FindFilePath(directory, name + GetExtension(typeof(T))));
+
+            if (string.IsNullOrEmpty(path))
+            {
+                Debug.LogErrorFormat("LoadAsset() => 鍔犺浇涓嶅埌璧勬簮: {1} {0}." + path, name, directory);
+                return asset;
+            }
+        }
+
         asset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(path);
 #else
+        //TODO YYL ASSET BUNDLE閮ㄥ垎瑕侀噸鍐欏鐞嗕竴涓�
         if (prefabBundle == null)
         {
             // string _path = GetAssetFilePath("builtin/prefabs");
@@ -115,7 +153,7 @@
 #endif
         if (asset == null)
         {
-            Debug.LogErrorFormat("LoadBuiltInPrefab() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
+            Debug.LogErrorFormat("LoadAsset() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
         }
 
         return asset;

--
Gitblit v1.8.0