예제 #1
0
        public static void Backup()
        {
            Debug.Log("Backup project");

            if (!BAR.Backup())
            {
                Debug.LogError($"Could not backup project!");
            }
        }
예제 #2
0
 /// <inheritdoc />
 protected override bool OnStepStart()
 {
     return(BAR.Backup());
 }
예제 #3
0
        protected static void showBAR()
        {
            if (Helper.isEditorMode)
            {
                if (!EditorApplication.isCompiling && !EditorApplication.isUpdating)
                {
                    if (!BAR.isBusy)
                    {
                        GUILayout.Space(3);
                        GUILayout.Label("Backup", EditorStyles.boldLabel);

                        if (Helper.isBackupEnabled)
                        {
                            GUI.enabled = !Helper.isDeleting;

                            if (GUILayout.Button(new GUIContent(" Backup", Helper.Action_Backup, "Backup the project")))
                            {
                                if (!Config.CONFIRM_BACKUP || EditorUtility.DisplayDialog("Backup the project?",
                                                                                          (Config.USE_LEGACY ? Constants.ASSET_NAME + " will now close Unity and save the following folders: " : "Save the following folders: ") + System.Environment.NewLine +
                                                                                          (Config.COPY_ASSETS ? "• Assets" + System.Environment.NewLine : string.Empty) +
                                                                                          (Config.COPY_LIBRARY ? "• Library" + System.Environment.NewLine : string.Empty) +
                                                                                          (Config.COPY_SETTINGS ? "• ProjectSettings" + System.Environment.NewLine : string.Empty) +
                                                                                          (Config.COPY_PACKAGES ? "• Packages" + System.Environment.NewLine : string.Empty) +
                                                                                          System.Environment.NewLine +
                                                                                          "Backup directory: " + Config.PATH_BACKUP +
                                                                                          System.Environment.NewLine +
                                                                                          System.Environment.NewLine +
                                                                                          "This operation could take some time." + System.Environment.NewLine + System.Environment.NewLine + "Would you like to start the backup?", "Yes", "No"))
                                {
                                    if (Config.DEBUG)
                                    {
                                        Debug.Log("Backup initiated");
                                    }

                                    BAR.Backup();

                                    GUIUtility.ExitGUI();
                                }
                            }

                            GUILayout.Label($"Last Backup:\t{(Helper.hasBackup ? Config.BACKUP_DATE.ToString() : "never")}");

                            //))GUILayout.Label($"Automatic Backup:\t{(EditorTask.AutoBackup.BackupInterval > 0 ? $"{Util.Config.AUTO_BACKUP_DATE.ToString()} (in {(Util.Config.AUTO_BACKUP_DATE - System.DateTime.Now).Minutes}min)" : "disabled")}");
                            GUILayout.Label($"Auto Backup:\t{(EditorTask.AutoBackup.BackupInterval > 0 ? $"{Util.Config.AUTO_BACKUP_DATE.ToString()} (in {Helper.FormatSecondsToHourMinSec((Util.Config.AUTO_BACKUP_DATE - System.DateTime.Now).TotalSeconds)})" : "disabled")}");

                            //GUILayout.Label("Last Backup:\t" + Config.BACKUP_DATE + " (" + Config.BACKUP_COUNT + ")");

                            Helper.SeparatorUI();

                            GUILayout.Label("Restore", EditorStyles.boldLabel);

                            if (Helper.hasBackup)
                            {
                                if (GUILayout.Button(new GUIContent(" Restore", Helper.Action_Restore, "Restore the project")))
                                {
                                    if (!Config.CONFIRM_RESTORE || EditorUtility.DisplayDialog("Restore the project?",
                                                                                               (Config.USE_LEGACY ? Constants.ASSET_NAME + " will now close Unity and restore the following folders: " : "Restore the following folders: ") + System.Environment.NewLine +
                                                                                               (Config.COPY_ASSETS ? "• Assets" + System.Environment.NewLine : string.Empty) +
                                                                                               (Config.COPY_LIBRARY ? "• Library" + System.Environment.NewLine : string.Empty) +
                                                                                               (Config.COPY_SETTINGS ? "• ProjectSettings" + System.Environment.NewLine : string.Empty) +
                                                                                               (Config.COPY_PACKAGES ? "• Packages" + System.Environment.NewLine : string.Empty) +
                                                                                               //System.Environment.NewLine +
                                                                                               //"Restore directory: " + Constants.APPLICATION_PATH +
                                                                                               //System.Environment.NewLine +
                                                                                               System.Environment.NewLine +
                                                                                               "This operation could take some time." + System.Environment.NewLine + System.Environment.NewLine + "Would you like to start the restore?", "Yes", "No"))
                                    {
                                        if (!Config.CONFIRM_RESTORE || !Config.CONFIRM_WARNING || !EditorUtility.DisplayDialog("Overwrite existing project?",
                                                                                                                               "This operation will overwrite ALL files. Any progress since the last backup will BE LOST!" + System.Environment.NewLine + System.Environment.NewLine + "Would you really want to continue?", "NO!", "Yes"))
                                        {
                                            if (Config.DEBUG)
                                            {
                                                Debug.Log("Restore initiated");
                                            }

                                            BAR.Restore();

                                            GUIUtility.ExitGUI();
                                        }
                                    }
                                }

                                GUILayout.Label("Last Restore:\t" + (Config.RESTORE_COUNT > 0 ? Config.RESTORE_DATE.ToString() : "never"));
                                //GUILayout.Label("Last Restore:\t" + Config.RESTORE_DATE + " (" + Config.RESTORE_COUNT + ")");
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("No backup found, restore is not possible. Please use 'Backup' first.", MessageType.Info);
                            }

                            GUI.enabled = true;
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("All backup folders are disabled. No actions possible.", MessageType.Error);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox($"{Constants.ASSET_NAME} is busy, please wait...", MessageType.Info);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Unity Editor is busy, please wait...", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info);
            }
        }