提交 f30a03de 编写于 作者: T tanghai

ResourcesComponent异步加载中加载ab用了一个同步方法,改为异步方法

上级 4962e5dc
......@@ -39,10 +39,10 @@ namespace ETModel
base.Dispose();
}
public Task<AssetBundle> LoadAsync(string bundleName)
public Task<AssetBundle> LoadAsync(string path)
{
this.tcs = new TaskCompletionSource<AssetBundle>();
this.request = AssetBundle.LoadFromFileAsync(Path.Combine(PathHelper.AppHotfixResPath, bundleName));
this.request = AssetBundle.LoadFromFileAsync(path);
return this.tcs.Task;
}
}
......
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<AssetsBundleLoaderAsync>())
{
p = Path.Combine(PathHelper.AppResPath, assetBundleName);
assetBundle = AssetBundle.LoadFromFile(p);
assetBundle = await assetsBundleLoaderAsync.LoadAsync(p);
}
if (assetBundle == null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册