private void RefreshBackup() { List <string> backups = new List <string>(GBackupFile.GetAllBackupNames()); Backups.Clear(); Backups.AddRange(backups); Repaint(); }
public static bool TryCreateInitialBackup(string namePrefix, int terrainGroupId, List <GTerrainResourceFlag> flags, bool showProgress = true) { bool success = false; #if UNITY_EDITOR if (showProgress) { GCommonGUI.ProgressBar("Backing up", "Creating terrain backup...", 1f); } #endif try { List <string> createdBackup = new List <string>(GBackupFile.GetAllBackupNames()); string prefix = GBackupFile.GetHistoryPrefix(namePrefix); string initialPrefix = GBackupFile.GetInitialHistoryPrefix(namePrefix); bool willCreateInitialBackup = true; for (int i = createdBackup.Count - 1; i >= 0; --i) { if (createdBackup[i].StartsWith(prefix)) { continue; } else if (createdBackup[i].StartsWith(initialPrefix)) { willCreateInitialBackup = false; break; } else { willCreateInitialBackup = true; break; } } if (willCreateInitialBackup) { string backupName = string.Format("{0}_{1}", initialPrefix, GBackupFile.GetBackupNameByTimeNow()); GUndoCompatibleBuffer.Instance.RecordUndo(); GBackup.Create(backupName, terrainGroupId, flags); success = true; } } catch (System.Exception e) { Debug.Log("Fail to creating terrain backup: " + e.ToString()); } finally { #if UNITY_EDITOR GCommonGUI.ClearProgressBar(); #endif } return(success); }