From 6033a0b34fbb8dffa192ededa0669f38c6072632 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 9 Jan 2025 10:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E6=A8=A1=E5=9D=97=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=8E=A7=E5=88=B6=E5=99=A8=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Controller/DeviceController.cs | 1 - Assets/Scripts/Controller/VarController.cs | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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))