예제 #1
0
        public static T GetOrCreateUniqueGameObject <T>()
            where T : ScriptComponent
        {
            bool hadInstance = UniqueGameObject <T> .HasInstance;

            if (!hadInstance && AGXUnity.Utils.PrefabUtils.IsEditingPrefab)
            {
                Debug.LogWarning($"Invalid to create {typeof( T ).FullName} while editing prefabs.");
                return(null);
            }

            if (UniqueGameObject <T> .Instance == null)
            {
                UniqueGameObject <T> .ResetDestroyedState();
            }

            T obj = UniqueGameObject <T> .Instance;

            if (!hadInstance && obj != null)
            {
                Undo.RegisterCreatedObjectUndo(obj.gameObject, "Created " + obj.name);
            }

            return(obj);
        }
예제 #2
0
파일: TopMenu.cs 프로젝트: hanyeah/AGXUnity
        public static T GetOrCreateUniqueGameObject <T>()
            where T : ScriptComponent
        {
            bool hadInstance = UniqueGameObject <T> .HasInstance;

            if (UniqueGameObject <T> .Instance == null)
            {
                UniqueGameObject <T> .ResetDestroyedState();
            }

            T obj = UniqueGameObject <T> .Instance;

            if (!hadInstance && obj != null)
            {
                Undo.RegisterCreatedObjectUndo(obj.gameObject, "Created " + obj.name);
            }

            return(obj);
        }