浏览代码

Fixed missing save file error

/UI
Bronson Zgeb 4 年前
当前提交
9ab7d6e5
共有 3 个文件被更改,包括 10 次插入3 次删除
  1. 4
      UOP1_Project/Assets/Scripts/SaveSystem/FileManager.cs
  2. 5
      UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs
  3. 4
      UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs

4
UOP1_Project/Assets/Scripts/SaveSystem/FileManager.cs


}
catch (Exception e)
{
Debug.LogError($"Failed to write to {fullPath} with exception {e}");
//Debug.LogError($"Failed to write to {fullPath} with exception {e}");
return false;
}
}

}
catch (Exception e)
{
Debug.LogError($"Failed to read from {fullPath} with exception {e}");
//Debug.LogError($"Failed to read from {fullPath} with exception {e}");
result = "";
return false;
}

5
UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs


}
}
}
public void WriteEmptySaveFile()
{
FileManager.WriteToFile(saveFilename, "");
}
}

4
UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs


private void Start()
{
_hasSaveData = saveSystem.LoadSaveDataFromDisk();
if (_hasSaveData)
{
startText.text = "Continue";

{
if (!_hasSaveData)
{
saveSystem.WriteEmptySaveFile();
//Start new game
onPlayButtonPress.RaiseEvent(locationsToLoad, showLoadScreen);
}

if (asyncOperationHandle.Status == AsyncOperationStatus.Succeeded)
{
var locationSo = asyncOperationHandle.Result;
onPlayButtonPress.RaiseEvent(new[] { (GameSceneSO)locationSo }, showLoadScreen);
onPlayButtonPress.RaiseEvent(new[] {(GameSceneSO)locationSo}, showLoadScreen);
}
}
}
正在加载...
取消
保存