public static string GetObjectTypeName(Object obj) { string objectType = "Unknown Type"; if (PrefabHelper.IsPrefab(obj, false, true, true)) { objectType = PrefabHelper.IsPrefabParent(obj) ? "Model" : "Model in Scene"; } if (PrefabHelper.IsPrefab(obj, true, false, true)) { objectType = "Prefab"; } if (!PrefabHelper.IsPrefab(obj, true, true, true)) { objectType = "Scene"; } if (PrefabHelper.IsPrefab(obj, true, false, true)) { if (PrefabHelper.IsPrefabParent(obj)) { objectType += " Asset"; } else if (PrefabHelper.IsPrefabRoot(obj)) { objectType += " Root"; } else { objectType += " Child"; } } return(objectType); }
public static string ObjectToAssetPath(Object obj, bool includingPrefabs = true) { obj = GetObjectIndirection(obj); if (includingPrefabs && PrefabHelper.IsPrefab(obj) && !PrefabHelper.IsPrefabParent(obj)) { return(AssetDatabase.GetAssetPath(PrefabHelper.GetPrefabParent(obj))); } return(AssetDatabase.GetAssetOrScenePath(obj)); }
public static void SetEditable(Object obj, bool editable) { //D.Log("Setting '" + obj + "' to " + (editable ? "editable" : "readonly")); if (obj != null && !AvoidGUILock(obj) && !IsBuiltinAsset(obj.GetAssetPath()) && !(obj is GameObject && PrefabHelper.IsPrefabParent(obj))) // Do not modify object flags for Project-Prefab GameObjects { if (editable && !IsEditable(obj)) { obj.hideFlags &= ~HideFlags.NotEditable; } if (!editable && IsEditable(obj)) { obj.hideFlags |= HideFlags.NotEditable; } } }
public static void ApplyAndCommit(Object obj, string commitMessage = "", bool showCommitDialog = false) { var gameObject = obj as GameObject; if (ObjectUtilities.ChangesStoredInScene(obj)) { SceneManagerUtilities.SaveActiveScene(); } if (PrefabHelper.IsPrefab(gameObject, true, false) && !PrefabHelper.IsPrefabParent(obj)) { PrefabHelper.ApplyPrefab(gameObject); } if (onHierarchyCommit != null) { onHierarchyCommit(obj); } VCCommands.Instance.CommitDialog(obj.ToAssetPaths(), showCommitDialog, commitMessage); }
public static bool ChangesStoredInPrefab(Object obj) { obj = GetObjectIndirection(obj); return(PrefabHelper.IsPrefabParent(obj) || PrefabHelper.IsPrefab(obj, true, false, true)); }
public static Object Revert(Object obj) { var gameObject = obj as GameObject; if (gameObject && PrefabHelper.IsPrefab(gameObject, true, false, true) && !PrefabHelper.IsPrefabParent(gameObject)) { return(RevertPrefab(gameObject)); } return(RevertObject(obj)); }