From d126255f4a6c9b8422dd2d1ac6b4d970bc124b7f Mon Sep 17 00:00:00 2001 From: Ader Alisma 01 Date: Sun, 10 Nov 2024 13:32:33 -0500 Subject: [PATCH] Destroys unitTree onDestroy --- Assets/Scripts/Ally/AllyUpgrade.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Ally/AllyUpgrade.cs b/Assets/Scripts/Ally/AllyUpgrade.cs index 17f127e..dfdd8b9 100644 --- a/Assets/Scripts/Ally/AllyUpgrade.cs +++ b/Assets/Scripts/Ally/AllyUpgrade.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; @@ -31,7 +30,7 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler AssignUpgrades(canvas); } } - + } else { @@ -53,4 +52,13 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler button.Initialize(_upgradeList[i], gameObject, canvas); } } - }} + } + + private void OnDestroy() + { + if (_instance != null) + { + Destroy(_instance); + } + } +}