static bool OnOperationStarting(OperationType operationType, VersionControlStatus[] statuses)
        {
            if (operationType == OperationType.Revert || operationType == OperationType.Commit)
            {
                foreach (var status in statuses)
                {
                    // Save Scenes
                    for (int i = 0, length = SceneManager.sceneCount; i < length; i++)
                    {
                        var scene = SceneManager.GetSceneAt(i);
                        if (scene.isLoaded && scene.isDirty)
                        {
                            if (status.assetPath.Contains(new ComposedString(scene.path)))
                            {
                                EditorSceneManager.SaveScene(scene);
                            }
                        }
                    }

                    // Save Prefabs
                    if (PrefabHelper.IsAssetPathOpenAsPrefabStage(status.assetPath.Compose()))
                    {
                        PrefabHelper.SaveOpenPrefabStage();
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        public static Object Revert(Object obj)
        {
            var gameObject = obj as GameObject;

            if (gameObject && PrefabHelper.IsPartofPrefabStage(gameObject))
            {
                PrefabHelper.SaveOpenPrefabStage();
            }
            return(RevertObject(obj));
        }
Exemplo n.º 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.IsPartofPrefabStage(gameObject))
            {
                PrefabHelper.SaveOpenPrefabStage();
            }
            if (onHierarchyCommit != null)
            {
                onHierarchyCommit(obj);
            }
            VCCommands.Instance.CommitDialog(obj.ToAssetPaths(), includeDependencies: true, showUserConfirmation: showCommitDialog, commitMessage: commitMessage);
        }