40 Debug.unityLogger.Log(LogType.Warning,
MASTER_TAG,
"Singleton Instance '{0}' won't be created while application is quitting.");
48#if UNITY_2020_1_OR_NEWER
49 Object[] existingInstances = FindObjectsByType<T>(FindObjectsSortMode.None);
51 Object[] existingInstances = FindObjectsOfType(typeof(T));
54 if (existingInstances.Length <= 0)
56 GameObject singleton =
new GameObject();
57 instance = singleton.AddComponent<T>();
58 instance.name =
"Singleton_" + typeof(T).ToString();
64 instance = existingInstances[0] as T;
66 if (existingInstances.Length > 1)
68 Debug.unityLogger.Log(LogType.Error,
MASTER_TAG,
"Multiple instances of '{0}' found. There should only be 1 instances. Reopening the scene might fix the problem.");
74 Debug.unityLogger.Log(LogType.Assert,
MASTER_TAG,
"An instance was found and is still null.");