void DemoLoad(bool forceFromDisk) { // Don't do more than one load/save at a time if (!_isLoading && !_isSaving) { _isLoading = true; // Load the save and handle the results. GameSaveSystem.Load <DemoGameSave>("demosave", forceFromDisk) .OnSuccess(f => { if (f.value.usedBackupFile) { Debug.LogWarning("Load successful, but a backup file was used.", this); } else { Debug.Log("Load successful. Was cached? " + f.value.wasCached, this); } _gameSave = f.value.save; }) .OnError(f => { Debug.LogWarning("Load failed: " + f.error.Message + ". Creating new game save for demo.", this); _gameSave = new DemoGameSave(); }) .OnComplete(f => _isLoading = false); } }
void DemoSave() { // Don't do more than one load/save at a time if (!_isLoading && !_isSaving && _gameSave != null) { _isSaving = true; // Save our game save and handle the result GameSaveSystem.Save <DemoGameSave>("demosave", _gameSave) .OnSuccess(f => Debug.Log("Save successful.", this)) .OnError(f => Debug.LogWarning("Save failed: " + f.error.Message, this)) .OnComplete(f => _isSaving = false); } }
void Start() { // Games have to Initialize the system before using it. GameSaveSystem.Initialize(new GameSaveSystemSettings { companyName = "Test Company", gameName = "Test Game", useRollingBackups = true, backupCount = 2 }); // Log the output folder where the saves will be Debug.Log("Save location: " + GameSaveSystem.saveLocation, this); // Use a coroutine to update the animated dots for our text StartCoroutine(UpdateDots()); }