From 4799acc1edb1cfb6449bf7555e6106634e4a3fc6 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Sun, 19 Jan 2025 13:33:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Controller/ScoreController.cs | 13 +++++++++++-- Assets/Scripts/UI/UIModuleSelect.cs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Controller/ScoreController.cs b/Assets/Scripts/Controller/ScoreController.cs index a52be7ae..460ded4d 100644 --- a/Assets/Scripts/Controller/ScoreController.cs +++ b/Assets/Scripts/Controller/ScoreController.cs @@ -17,8 +17,15 @@ public class ScoreController : MonoSingleton { base.OnSingletonInit(); InitData(); - TypeEventSystem.Global.Register(OnStart).UnRegisterWhenGameObjectDestroyed(gameObject); - TypeEventSystem.Global.Register(OnQuit).UnRegisterWhenGameObjectDestroyed(gameObject); + } + + public void Init() + { + if (Global.Instance.curModule.type == "Exam" || Global.Instance.curModule.type == "All") + { + TypeEventSystem.Global.Register(OnStart); + TypeEventSystem.Global.Register(OnQuit); + } } public void InitData() @@ -92,6 +99,8 @@ public class ScoreController : MonoSingleton var data = moduleDict[Global.Instance.curModule.ModuleName]; var scoreDict = data.scoreDict; scoreDict.Clear(); + TypeEventSystem.Global.UnRegister(OnStart); + TypeEventSystem.Global.UnRegister(OnQuit); } diff --git a/Assets/Scripts/UI/UIModuleSelect.cs b/Assets/Scripts/UI/UIModuleSelect.cs index 279c9bb3..bb867b3c 100644 --- a/Assets/Scripts/UI/UIModuleSelect.cs +++ b/Assets/Scripts/UI/UIModuleSelect.cs @@ -84,7 +84,7 @@ namespace QFramework.Example var machin = StateMachineController.Instance; var op = OperationController.Instance; var dev = DeviceController.Instance; - var score = ScoreController.Instance; + ScoreController.Instance.Init(); UIKit.OpenPanelAsync().ToAction().StartGlobal(() => {