public async Task LoadAssetBundleFromFileAsync(string name, IProgress<float> progress = null) { string bundleLocalPath = Utilites.GetAssetBundleLocalPath(name); #if UNITY_EDITOR && !DISABLE_EDITOR_ASSET_BUNDLE_SIMULATION if (!File.Exists(bundleLocalPath)) return; #endif AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(bundleLocalPath); TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(); request.completed += _ => tcs.TrySetResult(true); await tcs.Task; if (request.assetBundle == null) throw new Exception($"Failed to load asset bundle '{name}'"); _loadedAssetBundles.Add(name, request.assetBundle); }
public void LoadAssetBundleFromFile(string name) { string bundleLocalPath = Utilites.GetAssetBundleLocalPath(name); #if UNITY_EDITOR && !DISABLE_EDITOR_ASSET_BUNDLE_SIMULATION if (!File.Exists(bundleLocalPath)) return; #endif Stopwatch stopwatch = Stopwatch.StartNew(); AssetBundle assetBundle = AssetBundle.LoadFromFile(bundleLocalPath); if (assetBundle == null) throw new Exception($"Failed to load asset bundle '{name}'"); _loadedAssetBundles.Add(name, assetBundle); stopwatch.Stop(); UnityEngine.Debug.Log($"Loading '{name}' bundle took {stopwatch.ElapsedMilliseconds} ms"); }