| | |
| | | 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) |