未验证 提交 9a4113ba 编写于 作者: xh704872627's avatar xh704872627 提交者: GitHub

修改EventSystem Publish bug (#229)

* EventSystem Publish Bug

修改EventSystem Publish 里面关于WaitAll的bug

* Update ETTaskHelper.cs

修改WaitAny当传入tasks长度为0卡住问题

* Update ResourcesComponent.cs

修改异步加载依赖资源为WaitAll,提升加载速度
上级 a1342297
......@@ -43,6 +43,11 @@ namespace ET
public static async ETTask WaitAny<T>(ETTask<T>[] tasks)
{
if (tasks?.Length == 0)
{
return;
}
CoroutineBlocker coroutineBlocker = new CoroutineBlocker(2);
foreach (ETTask<T> task in tasks)
{
......@@ -60,6 +65,11 @@ namespace ET
public static async ETTask WaitAny(ETTask[] tasks)
{
if (tasks?.Length == 0)
{
return;
}
CoroutineBlocker coroutineBlocker = new CoroutineBlocker(2);
foreach (ETTask task in tasks)
{
......
......@@ -613,26 +613,24 @@ namespace ET
{
return;
}
using var list = ListComponent<ETTask>.Create();
foreach (object obj in iEvents)
{
try
{
using var list = ListComponent<ETTask>.Create();
if (!(obj is AEvent<T> aEvent))
{
Log.Error($"event error: {obj.GetType().Name}");
continue;
}
list.List.Add(aEvent.Handle(a));
await ETTaskHelper.WaitAll(list.List);
}
catch (Exception e)
if (!(obj is AEvent<T> aEvent))
{
Log.Error(e);
Log.Error($"event error: {obj.GetType().Name}");
continue;
}
list.List.Add(aEvent.Handle(a));
}
try
{
await ETTaskHelper.WaitAll(list.List);
}
catch (Exception e)
{
Log.Error(e);
}
}
......
......@@ -455,18 +455,23 @@ namespace ET
string[] dependencies = GetSortedDependencies(assetBundleName);
//Log.Debug($"-----------dep load async start {assetBundleName} dep: {dependencies.ToList().ListToString()}");
using var tasts = ListComponent<ETTask>.Create();
async ETTask loadDependency(string dependency)
{
using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Resources, dependency.GetHashCode()))
{
await this.LoadOneBundleAsync(dependency, isScene);
}
}
foreach (string dependency in dependencies)
{
if (string.IsNullOrEmpty(dependency))
{
continue;
}
using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Resources, dependency.GetHashCode()))
{
await this.LoadOneBundleAsync(dependency, isScene);
}
tasts.List.Add(loadDependency(dependency));
}
await ETTaskHelper.WaitAll(tasts.List);
}
private async ETTask LoadOneBundleAsync(string assetBundleName, bool isScene)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册