diff --git a/Assets/Scripts/Controller/DeviceController.cs b/Assets/Scripts/Controller/DeviceController.cs index 09a22be4..1d9444a7 100644 --- a/Assets/Scripts/Controller/DeviceController.cs +++ b/Assets/Scripts/Controller/DeviceController.cs @@ -30,7 +30,6 @@ public class DeviceController : MonoSingleton private void OnQuit(OnModuleQuit quit) { deviceDict.Clear(); - deviceDict.Clear(); } private void OnStart(OnModuleStart start) diff --git a/Assets/Scripts/Controller/VarController.cs b/Assets/Scripts/Controller/VarController.cs index 48234840..d69ae194 100644 --- a/Assets/Scripts/Controller/VarController.cs +++ b/Assets/Scripts/Controller/VarController.cs @@ -1,4 +1,5 @@ using QFramework; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -12,9 +13,15 @@ public class VarController : MonoSingleton { base.OnSingletonInit(); varDict = new Dictionary(); + TypeEventSystem.Global.Register(OnQuit).UnRegisterWhenGameObjectDestroyed(gameObject); } + private void OnQuit(OnModuleQuit quit) + { + varDict.Clear(); + } + public void Set(string key, float value) { if (varDict.ContainsKey(key))