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 bool ShouldVCRevert(Object obj) { var assetStatus = obj.GetAssetStatus(); var material = obj as Material; return (material && ManagedByRepository(assetStatus) || ((assetStatus.lockStatus == VCLockStatus.LockedHere || assetStatus.ModifiedOrLocalEditAllowed()) && VCCommands.Instance.Ready) && 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)); }
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)); }