修复加载bug

This commit is contained in:
shenjianxing 2025-03-26 17:46:02 +08:00
parent 60e6691027
commit 1a7e0af9a4
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,7 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
mData = uiData as UIBackPackData ?? new UIBackPackData();
Content.RemoveAllChildren(); Content.RemoveAllChildren();
foreach (var device in mData.devices) foreach (var device in mData.devices)

View File

@ -17,7 +17,6 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
mData = uiData as UIOperationListData ?? new UIOperationListData(); mData = uiData as UIOperationListData ?? new UIOperationListData();
TypeEventSystem.Global.Register<OnOperationChanged>((arg) => Refresh()).UnRegisterWhenGameObjectDestroyed(gameObject);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
@ -80,8 +79,9 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnOperationChanged>((arg) => Refresh());
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(this); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(this);
Refresh();
} }
public void Refresh() public void Refresh()
@ -149,9 +149,17 @@ namespace QFramework.Example
protected override void OnShow() protected override void OnShow()
{ {
Refresh();
} }
protected override void OnClose() protected override void OnClose()
{ {
TypeEventSystem.Global.UnRegister<OnOperationChanged>((arg) => Refresh());
}
public override void Hide()
{
base.Hide();
TypeEventSystem.Global.UnRegister<OnOperationChanged>((arg) => Refresh());
} }
} }
} }