Revert() публичный статический Метод

Reverts the specified assets by undoing any changes done since last time you synced.

public static Revert ( Asset asset, RevertMode mode ) : Task
asset Asset The asset to be reverted.
mode RevertMode How to revert the assets.
Результат Task
Пример #1
0
        public void OnGUI()
        {
            float h = (position.height - 122) / 2;

            // TODO: Show the reason: Who has the exclusive lock?
            GUILayout.Label("Some files could not be checked out:", EditorStyles.boldLabel);

            Rect r1 = new Rect(6, 40, position.width - 12, h);

            GUILayout.BeginArea(r1);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndArea();
            checkoutFailureList.OnGUI(new Rect(r1.x + 2, r1.y + 2, r1.width - 4, r1.height - 4), true);

            GUILayout.Space(20 + h);
            GUILayout.Label("The following files were successfully checked out:", EditorStyles.boldLabel);

            Rect r2 = new Rect(6, 40 + h + 40, position.width - 12, h);

            GUILayout.BeginArea(r2);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndArea();
            checkoutSuccessList.OnGUI(new Rect(r2.x + 2, r2.y + 2, r2.width - 4, r2.height - 4), true);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();

            EditorUserSettings.showFailedCheckout = !GUILayout.Toggle(!EditorUserSettings.showFailedCheckout, "Don't show this window again.");

            GUILayout.FlexibleSpace();

            bool enabled = GUI.enabled;

            GUI.enabled = checkoutFailureList.Size > 0;

            if (GUILayout.Button("Retry Check Out"))
            {
                Provider.Checkout(assetList, CheckoutMode.Exact);
            }

            GUI.enabled = checkoutSuccessList.Size > 0;

            if (GUILayout.Button("Revert Unchanged"))
            {
                Provider.Revert(assetList, RevertMode.Unchanged).SetCompletionAction(CompletionAction.UpdatePendingWindow);
                Provider.Status(assetList);
                Close();
            }

            GUI.enabled = enabled;

            if (GUILayout.Button("OK"))
            {
                Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(12);
        }
Пример #2
0
        void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel);
            GUILayout.FlexibleSpace();

            // I would use GUIUtility.GetLastRect() here after the box but that seems to have wierd side effects.
            Rect r1 = new Rect(6, 40, position.width - 12, position.height - 82);

            GUILayout.BeginArea(r1);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.EndArea();
            revertList.OnGUI(new Rect(r1.x + 2, r1.y + 2, r1.width - 4, r1.height - 4), true);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Cancel"))
            {
                Close();
            }

            if (assetList.Count > 0 && GUILayout.Button("Revert"))
            {
                string openScenes = "";
                foreach (Asset a in assetList)
                {
                    Scene openScene = SceneManager.GetSceneByPath(a.path);
                    if ((openScene.IsValid()) && (openScene.isLoaded))
                    {
                        openScenes += openScene.path + "\n";
                    }
                }

                if (openScenes.Length > 0)
                {
                    bool continueRevert = EditorUtility.DisplayDialog("Revert open scene(s)?",
                                                                      "You are about to revert your currently open scene(s):\n\n" +
                                                                      openScenes + "\nContinuing will remove all unsaved changes.",
                                                                      "Continue", "Cancel");
                    if (!continueRevert)
                    {
                        Close();
                        return;
                    }
                }

                Provider.Revert(assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                InspectorWindow.RefreshInspectors();
                Close();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(12);
        }
Пример #3
0
        public void OnGUI()
        {
            float num = (base.position.height - 122f) / 2f;

            GUILayout.Label("Some files could not be checked out:", EditorStyles.boldLabel, new GUILayoutOption[0]);
            Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, num);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.checkoutFailureList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
            GUILayout.Space(20f + num);
            GUILayout.Label("The following files were successfully checked out:", EditorStyles.boldLabel, new GUILayoutOption[0]);
            Rect screenRect2 = new Rect(6f, 40f + num + 40f, base.position.width - 12f, num);

            GUILayout.BeginArea(screenRect2);
            GUILayout.Box(string.Empty, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.checkoutSuccessList.OnGUI(new Rect(screenRect2.x + 2f, screenRect2.y + 2f, screenRect2.width - 4f, screenRect2.height - 4f), true);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            EditorUserSettings.showFailedCheckout = !GUILayout.Toggle(!EditorUserSettings.showFailedCheckout, "Don't show this window again.", new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            bool enabled = GUI.enabled;

            GUI.enabled = (this.checkoutFailureList.Size > 0);
            if (GUILayout.Button("Retry Check Out", new GUILayoutOption[0]))
            {
                Provider.Checkout(this.assetList, CheckoutMode.Exact);
            }
            GUI.enabled = (this.checkoutSuccessList.Size > 0);
            if (GUILayout.Button("Revert Unchanged", new GUILayoutOption[0]))
            {
                Provider.Revert(this.assetList, RevertMode.Unchanged).SetCompletionAction(CompletionAction.UpdatePendingWindow);
                Provider.Status(this.assetList);
                base.Close();
            }
            GUI.enabled = enabled;
            if (GUILayout.Button("OK", new GUILayoutOption[0]))
            {
                base.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
        }
Пример #4
0
        private void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect screenRect = new Rect(6f, 40f, this.position.width - 12f, this.position.height - 82f);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[2]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.revertList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            if (this.assetList.Count > 0 && GUILayout.Button("Revert"))
            {
                string str = string.Empty;
                using (List <Asset> .Enumerator enumerator = this.assetList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Scene sceneByPath = SceneManager.GetSceneByPath(enumerator.Current.path);
                        if (sceneByPath.IsValid() && sceneByPath.isLoaded)
                        {
                            str = str + sceneByPath.path + "\n";
                        }
                    }
                }
                if (str.Length > 0 && !EditorUtility.DisplayDialog("Revert open scene(s)?", "You are about to revert your currently open scene(s):\n\n" + str + "\nContinuing will remove all unsaved changes.", "Continue", "Cancel"))
                {
                    this.Close();
                    return;
                }
                Provider.Revert(this.assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
        }
Пример #5
0
        private void OnGUI()
        {
            GUILayout.Label("Revert Files", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, base.position.height - 82f);

            GUILayout.BeginArea(screenRect);
            GUILayout.Box(string.Empty, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });
            GUILayout.EndArea();
            this.revertList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
            {
                base.Close();
            }
            if (this.assetList.Count > 0 && GUILayout.Button("Revert", new GUILayoutOption[0]))
            {
                foreach (Asset current in this.assetList)
                {
                    if (current.path == EditorApplication.currentScene)
                    {
                        if (!EditorUtility.DisplayDialog("Revert open scene?", "You are about to revert your currently open scene:\n\n" + EditorApplication.currentScene + "\n\nContinuing will remove all unsaved changes.", "Continue", "Cancel"))
                        {
                            base.Close();
                            return;
                        }
                        break;
                    }
                }
                Provider.Revert(this.assetList, RevertMode.Normal).Wait();
                WindowPending.UpdateAllWindows();
                AssetDatabase.Refresh();
                base.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(12f);
        }