diff --git a/BlueWater/Assets/02.Scripts/Ai/AiController.cs b/BlueWater/Assets/02.Scripts/Ai/AiController.cs index 52e87b8d1..3a28f2ad9 100644 --- a/BlueWater/Assets/02.Scripts/Ai/AiController.cs +++ b/BlueWater/Assets/02.Scripts/Ai/AiController.cs @@ -39,7 +39,7 @@ namespace BlueWaterProject [EnableIf("alwaysFalse")] [EnumToggleButtons] [SerializeField] protected AttackerType attackerType; - private bool alwaysFalse = false; + private bool alwaysFalse; [EnableIf("alwaysFalse")] [ShowIf("attackerType", AttackerType.OFFENSE)] diff --git a/BlueWater/Assets/02.Scripts/Ai/Unit/UnitController.cs b/BlueWater/Assets/02.Scripts/Ai/Unit/UnitController.cs index 60d40c44c..9e7876522 100644 --- a/BlueWater/Assets/02.Scripts/Ai/Unit/UnitController.cs +++ b/BlueWater/Assets/02.Scripts/Ai/Unit/UnitController.cs @@ -155,21 +155,16 @@ namespace BlueWaterProject } [PropertyOrder(-7)] - [EnableIf("@unit.soliderCount > 0 && attackerType != AttackerType.NONE")] [GUIColor(1, 0, 0)] - [Button("타입 초기화")] - private void ResetTypeAll() + [Button("유닛 초기화")] + private void ResetUnit() { + unit = new Unit(); + attackIslandInfo = null; attackerType = AttackerType.NONE; offenseType = OffenseType.NONE; defenseType = DefenseType.NONE; - - foreach (var soldier in unit.soldierList) - { - soldier.SetAttackerType(attackerType); - soldier.SetOffenseType(offenseType); - soldier.SetDefenseType(defenseType); - } + isClickedTypeAllButton = false; } [PropertyOrder(1)] diff --git a/BlueWater/Assets/02.Scripts/Ai/Unit/UnitManager.cs b/BlueWater/Assets/02.Scripts/Ai/Unit/UnitManager.cs index 173f13b61..38f49bae7 100644 --- a/BlueWater/Assets/02.Scripts/Ai/Unit/UnitManager.cs +++ b/BlueWater/Assets/02.Scripts/Ai/Unit/UnitManager.cs @@ -57,9 +57,8 @@ namespace BlueWaterProject #region Unity built-in function - protected override void Awake() + protected override void OnAwake() { - base.Awake(); GroundLayer = LayerMask.GetMask("Ground"); InitUnitMatrices(); InitPlayerUnitList(); diff --git a/BlueWater/Assets/02.Scripts/Utility/Singletone.cs b/BlueWater/Assets/02.Scripts/Utility/Singletone.cs index a45e2d0f7..6a5d3207e 100644 --- a/BlueWater/Assets/02.Scripts/Utility/Singletone.cs +++ b/BlueWater/Assets/02.Scripts/Utility/Singletone.cs @@ -24,6 +24,19 @@ public abstract class Singleton : Singleton where T : MonoBehaviour { if (Quitting) { + if (_instance != null) + return _instance; + var instances = FindObjectsOfType(); + var count = instances.Length; + if (count > 0) + { + if (count == 1) + return _instance = instances[0]; + Debug.LogWarning($"[{nameof(Singleton)}<{typeof(T)}>] There should never be more than one {nameof(Singleton)} of type {typeof(T)} in the scene, but {count} were found. The first instance found will be used, and all others will be destroyed."); + for (var i = 1; i < instances.Length; i++) + Destroy(instances[i]); + return _instance = instances[0]; + } Debug.LogWarning($"[{nameof(Singleton)}<{typeof(T)}>] Instance will not be returned because the application is quitting."); // ReSharper disable once AssignNullToNotNullAttribute return null;