diff --git a/Assets/Scripts/UI/UIBackPack.cs b/Assets/Scripts/UI/UIBackPack.cs index cfbb880b..00b392b4 100644 --- a/Assets/Scripts/UI/UIBackPack.cs +++ b/Assets/Scripts/UI/UIBackPack.cs @@ -27,6 +27,7 @@ namespace QFramework.Example protected override void OnOpen(IUIData uiData = null) { + mData = uiData as UIBackPackData ?? new UIBackPackData(); Content.RemoveAllChildren(); foreach (var device in mData.devices) diff --git a/Assets/Scripts/UI/UIOperationList.cs b/Assets/Scripts/UI/UIOperationList.cs index 6c282f59..d294edc8 100644 --- a/Assets/Scripts/UI/UIOperationList.cs +++ b/Assets/Scripts/UI/UIOperationList.cs @@ -17,7 +17,6 @@ namespace QFramework.Example protected override void OnInit(IUIData uiData = null) { mData = uiData as UIOperationListData ?? new UIOperationListData(); - TypeEventSystem.Global.Register((arg) => Refresh()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } @@ -80,8 +79,9 @@ namespace QFramework.Example protected override void OnOpen(IUIData uiData = null) { + TypeEventSystem.Global.Register((arg) => Refresh()); TypeEventSystem.Global.Register(OnStepChanged).UnRegisterWhenDisabled(this); - Refresh(); + } public void Refresh() @@ -149,9 +149,17 @@ namespace QFramework.Example protected override void OnShow() { + Refresh(); } protected override void OnClose() { + TypeEventSystem.Global.UnRegister((arg) => Refresh()); + } + + public override void Hide() + { + base.Hide(); + TypeEventSystem.Global.UnRegister((arg) => Refresh()); } } }