Skip to content

Commit

Permalink
关闭时 添加协程锁
Browse files Browse the repository at this point in the history
  • Loading branch information
LiShengYang-yiyi committed Sep 27, 2024
1 parent c833c3e commit cb7c57f
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public static async ETTask<bool> ClosePanelAsync(this YIUIMgrComponent self, str
#endif

self.m_PanelCfgMap.TryGetValue(panelName, out var info);

if (info?.UIBase == null) return true; //没有也算成功关闭

EventSystem.Instance?.Publish(
self.Root(),
var coroutineLockCode = info.PanelLayer == EPanelLayer.Panel ? YIUIConstHelper.Const.UIProjectName.GetHashCode() : panelName.GetHashCode();

using var coroutineLock = await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.YIUIFramework, coroutineLockCode);

EventSystem.Instance?.Publish(self.Root(),
new YIUIEventPanelCloseBefore
{
UIPkgName = info.PkgName, UIResName = info.ResName, UIComponentName = info.Name,
Expand Down Expand Up @@ -90,8 +92,7 @@ internal static bool DestroyPanel(this YIUIMgrComponent self, string panelName)
Debug.Log($"<color=yellow> 关闭一个窗口(被直接摧毁的): {panelName} </color>");
#endif

EventSystem.Instance?.Publish(
self.Root(),
EventSystem.Instance?.Publish(self.Root(),
new YIUIEventPanelCloseBefore
{
UIPkgName = info.PkgName, UIResName = info.ResName, UIComponentName = info.Name,
Expand Down Expand Up @@ -148,12 +149,11 @@ public static async ETTask<bool> HomePanel(this YIUIMgrComponent self, string ho
if (forceHome != null)
{
await self.CloseAll(EPanelLayer.Panel, EPanelOption.IgnoreClose, tween);
return await EventSystem.Instance?.YIUIInvokeAsync<YIUIInvokeRootOpenPanel, ETTask<bool>>(
new YIUIInvokeRootOpenPanel
{
Root = forceHome,
PanelName = homeName
});
return await EventSystem.Instance?.YIUIInvokeAsync<YIUIInvokeRootOpenPanel, ETTask<bool>>(new YIUIInvokeRootOpenPanel
{
Root = forceHome,
PanelName = homeName
});
}
}

Expand All @@ -165,4 +165,4 @@ public static async ETTask HomePanel<T>(this YIUIMgrComponent self, bool tween =
await self.HomePanel(typeof(T).Name, tween, forceHome);
}
}
}
}

0 comments on commit cb7c57f

Please sign in to comment.