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); }
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); }