修复切换bug

This commit is contained in:
shenjianxing 2025-01-19 13:33:25 +08:00
parent 15a78a6296
commit 4799acc1ed
2 changed files with 12 additions and 3 deletions

View File

@ -17,8 +17,15 @@ public class ScoreController : MonoSingleton<ScoreController>
{ {
base.OnSingletonInit(); base.OnSingletonInit();
InitData(); InitData();
TypeEventSystem.Global.Register<OnModuleStart>(OnStart).UnRegisterWhenGameObjectDestroyed(gameObject); }
TypeEventSystem.Global.Register<OnModuleQuit>(OnQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
public void Init()
{
if (Global.Instance.curModule.type == "Exam" || Global.Instance.curModule.type == "All")
{
TypeEventSystem.Global.Register<OnModuleStart>(OnStart);
TypeEventSystem.Global.Register<OnModuleQuit>(OnQuit);
}
} }
public void InitData() public void InitData()
@ -92,6 +99,8 @@ public class ScoreController : MonoSingleton<ScoreController>
var data = moduleDict[Global.Instance.curModule.ModuleName]; var data = moduleDict[Global.Instance.curModule.ModuleName];
var scoreDict = data.scoreDict; var scoreDict = data.scoreDict;
scoreDict.Clear(); scoreDict.Clear();
TypeEventSystem.Global.UnRegister<OnModuleStart>(OnStart);
TypeEventSystem.Global.UnRegister<OnModuleQuit>(OnQuit);
} }

View File

@ -84,7 +84,7 @@ namespace QFramework.Example
var machin = StateMachineController.Instance; var machin = StateMachineController.Instance;
var op = OperationController.Instance; var op = OperationController.Instance;
var dev = DeviceController.Instance; var dev = DeviceController.Instance;
var score = ScoreController.Instance; ScoreController.Instance.Init();
UIKit.OpenPanelAsync<UIRightTop>().ToAction().StartGlobal(() => UIKit.OpenPanelAsync<UIRightTop>().ToAction().StartGlobal(() =>
{ {