From 9fb3c8e114a67c0cdf353b32b1b50e90414fd597 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 25 二月 2026 16:34:07 +0800
Subject: [PATCH] Merge branch 'master' into h5version

---
 Main/ResModule/ResManager.cs |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Main/ResModule/ResManager.cs b/Main/ResModule/ResManager.cs
index 1e721fa..524efb3 100644
--- a/Main/ResModule/ResManager.cs
+++ b/Main/ResModule/ResManager.cs
@@ -234,6 +234,27 @@
         LoadAssetAsyncInternal<T>(directory, name, callBack, needExt);
     }
 
+    public async UniTask<T> LoadAssetAsync<T>(string directory, string name) where T : UnityEngine.Object
+    {
+        return await LoadAssetAsync<T>(directory, name, needExt: true);
+    }
+
+    public async UniTask<T> LoadAssetAsync<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
+    {
+        var tcs = new UniTaskCompletionSource<T>();
+        LoadAssetAsync<T>(directory, name, (isLoaded, asset) => {
+            if (isLoaded)
+            {
+                tcs.TrySetResult(asset as T);
+            }
+            else
+            {
+                tcs.TrySetException(new Exception($"Failed to load asset: {directory}/{name}"));
+            }
+        }, needExt);
+        return await tcs.Task;
+    }
+
     private void LoadSpriteAsync<T>(string atlasName, string spriteName, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object
     {
         if (!AssetSource.isUseAssetBundle)

--
Gitblit v1.8.0