Force awakening if needed for Singleton

This commit is contained in:
Antoine H 2021-01-19 10:46:07 +01:00
parent a940cb64ba
commit aa850a7c0b
4 changed files with 15 additions and 10 deletions

View file

@ -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<GameSystem>().Awake();
return _instance;
}
}