14 private static T _Instance;
15 public static T Instance
19 if (_Instance == null)
21 T[] objects = FindObjectsOfType<T>();
22 if (objects.Length == 1)
24 _Instance = objects[0];
26 else if (objects.Length > 1)
28 Debug.LogErrorFormat(
"Expected exactly 1 {0} but found {1}", typeof(T).ToString(), objects.Length);