Exemple #1
0
        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);
        }
Exemple #2
0
 public Maintainer(SingletonLifeCycleRule lifeCycle)
 {
     _lifeCycle = lifeCycle;
 }
Exemple #3
0
        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);
        }
Exemple #4
0
 public ConfigAttribute(SingletonLifeCycleRule defaultLifeCycle)
 {
     this.DefaultLifeCycle = defaultLifeCycle;
 }