Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 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;
         }
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public static bool ChangesStoredInPrefab(Object obj)
 {
     obj = GetObjectIndirection(obj);
     return(PrefabHelper.IsPrefabParent(obj) || PrefabHelper.IsPrefab(obj, true, false, true));
 }
Exemplo n.º 6
0
        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));
        }