Exemplo n.º 1
0
        private static Object RevertObject(Object obj)
        {
            if (ObjectUtilities.ChangesStoredInScene(obj))
            {
                SceneManagerUtilities.SaveActiveScene();
            }
            bool success = VCCommands.Instance.Revert(obj.ToAssetPaths());

            if (success && onHierarchyReverted != null)
            {
                onHierarchyReverted(obj);
            }
            return(obj);
        }
Exemplo n.º 2
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.º 3
0
        public bool CommitDialog(IEnumerable <string> assets, bool showUserConfirmation = true, string commitMessage = "")
        {
            int initialAssetCount = assets.Count();

            if (initialAssetCount == 0)
            {
                return(true);
            }

            assets = assets.AddFilesInFolders().AddFolders(vcc).AddMoveMatches(vcc);
            var dependencies  = VCSettings.IncludeDepedenciesAsDefault ? assets.GetDependencies().AddFilesInFolders().AddFolders(vcc).Concat(assets.AddDeletedInFolders(vcc)) : new List <string>();
            var allAssets     = assets.Concat(dependencies).Distinct().ToList();
            var localModified = allAssets.LocalModified(vcc);

            if (assets.Contains(SceneManagerUtilities.GetCurrentScenePath()))
            {
                SceneManagerUtilities.SaveCurrentModifiedScenesIfUserWantsTo();
            }
            if (PreCommit != null)
            {
                PreCommit(allAssets);
            }
            if (VCSettings.RequireLockBeforeCommit && localModified.Any())
            {
                string title   = string.Format("{0} '{1}' files?", Terminology.getlock, Terminology.localModified);
                string message = string.Format("You are trying to commit files which are '{0}'.\nDo you want to '{1}' these files first?", Terminology.localModified, Terminology.getlock);
                if (EditorUtility.DisplayDialog(title, message, Terminology.getlock, "Abort"))
                {
                    GetLock(localModified);
                }
                else
                {
                    return(false);
                }
            }
            if (showUserConfirmation || initialAssetCount < (assets.Count() + dependencies.Count()))
            {
                return(OpenCommitDialogWindow(assets, dependencies));
            }
            return(Commit(assets, commitMessage, VCSettings.NonRecursiveAdd));
        }
Exemplo n.º 4
0
        internal static void RefreshEditableObject(GameObject gameObject)
        {
            bool editable           = ShouleBeEditable(gameObject);
            bool parentEditable     = gameObject.transform.parent ? ShouleBeEditable(gameObject.transform.parent.gameObject) : VCUtility.HaveAssetControl(SceneManagerUtilities.GetCurrentScenePath());
            bool prefabHeadEditable = PrefabHelper.IsPrefabRoot(gameObject) && parentEditable;

            if (prefabHeadEditable)
            {
                SetEditable(gameObject, true);
            }
            else
            {
                SetEditable(gameObject, editable);
            }

            foreach (var componentIt in gameObject.GetComponents <Component>())
            {
                if (prefabHeadEditable && componentIt == gameObject.transform)
                {
                    SetEditable(gameObject.transform, true);
                }
                else
                {
                    RefreshEditableComponent(gameObject, componentIt);
                }
            }
        }
Exemplo n.º 5
0
 public static bool ChangesStoredInScene(Object obj)
 {
     obj = GetObjectIndirection(obj);
     return(obj.GetAssetPath() == SceneManagerUtilities.GetCurrentScenePath());
 }