diff --git a/Assets/Scripts/GameSystems/ClientManager.cs b/Assets/Scripts/GameSystems/ClientManager.cs index 645d30a..06932a8 100644 --- a/Assets/Scripts/GameSystems/ClientManager.cs +++ b/Assets/Scripts/GameSystems/ClientManager.cs @@ -3,16 +3,18 @@ using System.Collections.Generic; using UnityEngine; using UnityEditor; + //Define the system managing the clients. (Singleton) //TODO: Switch to a registering approach for clients public sealed class ClientManager : MonoBehaviour { + public static string ClientManager_path="/GameSystem/ClientManager"; //Singleton private static ClientManager _instance=null; public static ClientManager Instance { get { - if(_instance is null) - Debug.LogError("Missing ClientManager instance"); + if(_instance is null) //Force Awakening if needed + GameObject.Find(ClientManager_path).GetComponent().Awake(); return _instance; } } @@ -139,7 +141,7 @@ public sealed class ClientManager : MonoBehaviour if(!ready) { - ClientContainer = GameObject.Find("/GameSystem/ClientManager"); + ClientContainer = GameObject.Find(ClientManager_path); if (ClientContainer is null) throw new System.Exception("No ClientManager found under GameSystem"); diff --git a/Assets/Scripts/GameSystems/EventManager.cs b/Assets/Scripts/GameSystems/EventManager.cs index 58454b4..cd1d885 100644 --- a/Assets/Scripts/GameSystems/EventManager.cs +++ b/Assets/Scripts/GameSystems/EventManager.cs @@ -7,12 +7,13 @@ using UnityEngine.AI; //TODO: Switch to a registering approach for events public sealed class EventManager : MonoBehaviour { + public static string EventManager_path="/GameSystem/EventManager"; //Singleton private static EventManager _instance=null; public static EventManager Instance { get { - if(_instance is null) - Debug.LogError("Missing EventManager instance"); + if(_instance is null) //Force Awakening if needed + GameObject.Find(EventManager_path).GetComponent().Awake(); return _instance; } } @@ -111,7 +112,7 @@ public sealed class EventManager : MonoBehaviour if(!ready) { - EventContainer = GameObject.Find("/GameSystem/EventManager"); + EventContainer = GameObject.Find(EventManager_path); if (EventContainer is null) throw new System.Exception("No EventManager found under GameSystem"); diff --git a/Assets/Scripts/GameSystems/GameSystem.cs b/Assets/Scripts/GameSystems/GameSystem.cs index 5ac3d44..2399f70 100644 --- a/Assets/Scripts/GameSystems/GameSystem.cs +++ b/Assets/Scripts/GameSystems/GameSystem.cs @@ -5,12 +5,13 @@ using UnityEngine; //Define the global game system of the service. (Singleton) public sealed class GameSystem : MonoBehaviour { + public static string GameSystem_path="/GameSystem"; //Singleton private static GameSystem _instance=null; public static GameSystem Instance { get { - if(_instance is null) - Debug.LogError("Missing GameSystem instance"); + if(_instance is null) //Force Awakening if needed + GameObject.Find(GameSystem_path).GetComponent().Awake(); return _instance; } } diff --git a/Assets/Scripts/GameSystems/StockManager.cs b/Assets/Scripts/GameSystems/StockManager.cs index 285db00..07665e5 100644 --- a/Assets/Scripts/GameSystems/StockManager.cs +++ b/Assets/Scripts/GameSystems/StockManager.cs @@ -6,12 +6,13 @@ using UnityEngine; //TODO : Update check stock of registered workshops public sealed class StockManager : MonoBehaviour { + public static string StockManager_path="/GameSystem/StockManager"; //Singleton private static StockManager _instance=null; public static StockManager Instance { get { - if(_instance is null) - Debug.LogError("Missing StockManager instance"); + if(_instance is null) //Force Awakening if needed + GameObject.Find(StockManager_path).GetComponent().Awake(); return _instance; } }