yyl
2 天以前 8d77144cfb756529507dc6927dcdcfd9f4a30750
Main/ResModule/ResManager.cs
@@ -6,6 +6,8 @@
using UnityEngine.Video;
using Spine.Unity;
using UnityEngine.UI;
using Cysharp.Threading.Tasks;
@@ -251,6 +253,22 @@
        LoadAssetAsyncInternal<T>(directory, name, callBack, needExt);
    }
    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 !UNITY_EDITOR