public static void Destroy(string name) { BaseBehavior singleton = null; m_singletons.TryGetValue(name, out singleton); if (singleton != null) { m_singletons.Remove(name); GameObject.DestroyImmediate(singleton.gameObject); } }
public static T Get <T>(string name) where T : BaseBehavior { BaseBehavior singleton = null; m_singletons.TryGetValue(name, out singleton); if (singleton == null) { GameObject newGo = new GameObject(name); singleton = newGo.AddComponent <T>(); m_singletons.Add(name, singleton); } return(singleton as T); }