Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        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);
        }