Пример #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);
        }
Пример #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));
 }
Пример #3
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);
        }
Пример #4
0
 public static void SetEditable(Object obj, bool editable)
 {
     //Debug.Log("Setting '" + obj + "' to " + (editable ? "editable" : "readonly"));
     if (AvoidGUILock(obj))
     {
         editable = true;
     }
     if (obj != null && !IsBuiltinAsset(obj.GetAssetPath()) && !EditorUtility.IsPersistent(obj) &&
         !(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;
         }
     }
 }
Пример #5
0
 public static bool ChangesStoredInPrefab(Object obj)
 {
     obj = GetObjectIndirection(obj);
     return(PrefabHelper.IsPrefabParent(obj) || PrefabHelper.IsPrefab(obj, true, false, true));
 }
Пример #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));
        }