public void SaveJson(T dataObject, bool overrideExisting) { Debug.Log(this + " Create Json"); JsonSaver.SaveAsJson( dataObject, DataObjectPath(dataObject), overrideExisting); OnSaveCompleted?.Invoke(dataObject); }
public void SaveAll() { m_jsonObject = new JObject(); foreach (var item in m_toSaveItems) { if (item == null) { Debug.LogError("Null item found. Did you forget to unsubscribe an ISaveCallbackReceiver?"); continue; } item.OnSaveData(this); } string json = m_jsonObject.ToString(); IOUtils.SafeWriteFileAsync(SaveFilePath, json, () => OnSaveCompleted?.Invoke()); }
private async void ShowSelectionBrowserCoroutine() { UIBlocking.Instance.Block(); var type = DataFileTypes.Maps; FileBrowser.SetFilters(showAllFilesFilter: false, new FileBrowser.Filter(type.ToString(), type.FileExtensionWithPeriod())); FileBrowser.SetDefaultFilter(type.FileExtensionWithPeriod()); var initialPath = FileSettings.Instance.GetFilePath(type); var initialDirectory = Path.GetDirectoryName(initialPath); await FileBrowser.WaitForSaveDialog( folderMode : false, initialPath : initialDirectory, initialFileName : LevelEntity_Level.Instance.Level.Name, title : $"Choose {type} save location", saveButtonText : "Save"); if (FileBrowser.Success) { var path = FileBrowser.Result; path = path.Replace(type.FileExtensionWithPeriod().ToLower(), type.FileExtensionWithPeriod()); try { SaveLevelToUnmergedMapFile(path); FileSettings.Instance.UpdateFilePath(type, filePath: path, loadFile: false); OnSaveCompleted?.Invoke(); } catch (Exception exception) { Debug.LogError($"Attempt to save file at path \"{path}\" failed with exception: {exception}"); } } UIBlocking.Instance.Unblock(); }