public static T CreateSpecialInstance <T>(string gameObjectName, SingletonLifeCycleRule lifeCycle) where T : Component, ISingleton { ISingleton single; if (_singletonRefs.TryGetValue(typeof(T), out single)) { return(single as T); } if (GameLoopEntry.ApplicationClosing) { return(null); } var go = new GameObject(gameObjectName); single = go.AddComponent <T>(); single.LifeCycle = lifeCycle; return(single as T); }
public Maintainer(SingletonLifeCycleRule lifeCycle) { _lifeCycle = lifeCycle; }
public static ISingleton CreateSpecialInstance(System.Type tp, string gameObjectName, SingletonLifeCycleRule lifeCycle) { if (!typeof(ISingleton).IsAssignableFrom(tp)) { throw new TypeArgumentMismatchException(tp, typeof(ISingleton), "tp"); } ISingleton single; if (_singletonRefs.TryGetValue(tp, out single)) { return(single); } if (GameLoopEntry.ApplicationClosing) { return(null); } var go = new GameObject(gameObjectName); single = go.AddComponent(tp) as ISingleton; single.LifeCycle = lifeCycle; return(single); }
public ConfigAttribute(SingletonLifeCycleRule defaultLifeCycle) { this.DefaultLifeCycle = defaultLifeCycle; }