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