diff --git a/Assets/Scripts/Controller/DeviceController.cs b/Assets/Scripts/Controller/DeviceController.cs index 5b7b7195..6071ad20 100644 --- a/Assets/Scripts/Controller/DeviceController.cs +++ b/Assets/Scripts/Controller/DeviceController.cs @@ -29,6 +29,10 @@ public class DeviceController : MonoSingleton private void OnQuit(OnModuleQuit quit) { + foreach (var item in deviceDict) + { + item.Value.item.Close(); + } deviceDict.Clear(); } diff --git a/Assets/Scripts/Item/DeviceItem.cs b/Assets/Scripts/Item/DeviceItem.cs index c1f33bc8..ef5d8d0a 100644 --- a/Assets/Scripts/Item/DeviceItem.cs +++ b/Assets/Scripts/Item/DeviceItem.cs @@ -18,7 +18,8 @@ public class DeviceItem : MonoBehaviour var effect = gameObject.GetOrAddComponent(); gameObject.GetOrAddComponent(); effect.outlineColor = Color.green; - StringEventSystem.Global.Register(Global.HighLightTrigger, OnHighLightTriggerEvent).UnRegisterWhenGameObjectDestroyed(gameObject); + Debug.LogError("Regitser £º " + gameObject.name); + StringEventSystem.Global.Register(Global.HighLightTrigger, OnHighLightTriggerEvent); } if (device.MeshCollider) { @@ -40,6 +41,14 @@ public class DeviceItem : MonoBehaviour } } + public void Close() + { + device = null; + tipItem = null; + Debug.LogError(gameObject.name); + StringEventSystem.Global.UnRegister(Global.HighLightTrigger, OnHighLightTriggerEvent); + } + private void OnHighLightTriggerEvent(string[] obj) { if (obj.Length > 0)