diff --git a/Unity/Assets/Scripts/Module/AssetsBundle/AssetsBundleLoaderAsync.cs b/Unity/Assets/Scripts/Module/AssetsBundle/AssetsBundleLoaderAsync.cs index 2486050faae0ee20a8e09bac7b6f5990930da566..5af25efc92a5483128eff3f7bb9f3283ed6b58cd 100644 --- a/Unity/Assets/Scripts/Module/AssetsBundle/AssetsBundleLoaderAsync.cs +++ b/Unity/Assets/Scripts/Module/AssetsBundle/AssetsBundleLoaderAsync.cs @@ -39,10 +39,10 @@ namespace ETModel base.Dispose(); } - public Task LoadAsync(string bundleName) + public Task LoadAsync(string path) { this.tcs = new TaskCompletionSource(); - this.request = AssetBundle.LoadFromFileAsync(Path.Combine(PathHelper.AppHotfixResPath, bundleName)); + this.request = AssetBundle.LoadFromFileAsync(path); return this.tcs.Task; } } diff --git a/Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs b/Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs index f5acb1d06118bbf47deca3bf673d2ccab1f5377b..37c05fa2b23a82735b2de5a4c8e475bb7335be19 100644 --- a/Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs +++ b/Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; @@ -48,7 +47,7 @@ namespace ETModel base.Dispose(); - //Log.Debug($"destroy assetbundle: {this.Name}"); + //Log.Debug($"desdroy assetbundle: {this.Name}"); this.AssetBundle?.Unload(true); } @@ -250,7 +249,7 @@ namespace ETModel assetBundleName = assetBundleName.ToLower(); string[] dependencies = ResourcesHelper.GetSortedDependencies(assetBundleName); - //Log.Debug($"-----------dep load {assetBundleName} dep: {dependencies.ToList().ListToString()}"); + // Log.Debug($"-----------dep load {assetBundleName} dep: {dependencies.ToList().ListToString()}"); foreach (string dependency in dependencies) { if (string.IsNullOrEmpty(dependency)) @@ -302,14 +301,14 @@ namespace ETModel string p = Path.Combine(PathHelper.AppHotfixResPath, assetBundleName); AssetBundle assetBundle = null; - if (File.Exists(p)) + if (!File.Exists(p)) { - assetBundle = AssetBundle.LoadFromFile(p); + p = Path.Combine(PathHelper.AppResPath, assetBundleName); } - else + + using (AssetsBundleLoaderAsync assetsBundleLoaderAsync = ComponentFactory.Create()) { - p = Path.Combine(PathHelper.AppResPath, assetBundleName); - assetBundle = AssetBundle.LoadFromFile(p); + assetBundle = await assetsBundleLoaderAsync.LoadAsync(p); } if (assetBundle == null)