19 Debug.LogWarning(
"[ApexSingleton] Singleton Instance '{0}' won't be created while application is quitting.");
27#if UNITY_2020_1_OR_NEWER
28 Object[] existingInstances = FindObjectsByType<T>(FindObjectsSortMode.None);
30 Object[] existingInstances = FindObjectsOfType(typeof(T));
33 if (existingInstances.Length <= 0)
35 GameObject singleton =
new GameObject();
36 instance = singleton.AddComponent<T>();
37 instance.name =
"Singleton_" + typeof(T).ToString();
43 instance = existingInstances[0] as T;
45 if (existingInstances.Length > 1)
47 Debug.LogError(
"[ApexSingleton] Multiple instances of '{0}' found. There should only be 1 instances. Reopening the scene might fix the problem.");
53 Debug.LogAssertion(
"[ApexSingleton] An instance was found and is still null.");