Skip to content

Commit aefe157

Browse files
author
Bronson Zgeb
committed
Fixed missing save file error
1 parent f043c51 commit aefe157

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

UOP1_Project/Assets/Scripts/SaveSystem/FileManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static bool WriteToFile(string fileName, string fileContents)
1515
}
1616
catch (Exception e)
1717
{
18-
Debug.LogError($"Failed to write to {fullPath} with exception {e}");
18+
//Debug.LogError($"Failed to write to {fullPath} with exception {e}");
1919
return false;
2020
}
2121
}
@@ -31,7 +31,7 @@ public static bool LoadFromFile(string fileName, out string result)
3131
}
3232
catch (Exception e)
3333
{
34-
Debug.LogError($"Failed to read from {fullPath} with exception {e}");
34+
//Debug.LogError($"Failed to read from {fullPath} with exception {e}");
3535
result = "";
3636
return false;
3737
}

UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,9 @@ public void SaveDataToDisk()
7575
}
7676
}
7777
}
78+
79+
public void WriteEmptySaveFile()
80+
{
81+
FileManager.WriteToFile(saveFilename, "");
82+
}
7883
}

UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class StartGame : MonoBehaviour
2323
private void Start()
2424
{
2525
_hasSaveData = saveSystem.LoadSaveDataFromDisk();
26+
2627
if (_hasSaveData)
2728
{
2829
startText.text = "Continue";
@@ -38,6 +39,7 @@ public void OnPlayButtonPress()
3839
{
3940
if (!_hasSaveData)
4041
{
42+
saveSystem.WriteEmptySaveFile();
4143
//Start new game
4244
onPlayButtonPress.RaiseEvent(locationsToLoad, showLoadScreen);
4345
}
@@ -65,7 +67,7 @@ public IEnumerator LoadSaveGame()
6567
if (asyncOperationHandle.Status == AsyncOperationStatus.Succeeded)
6668
{
6769
var locationSo = asyncOperationHandle.Result;
68-
onPlayButtonPress.RaiseEvent(new[] { (GameSceneSO)locationSo }, showLoadScreen);
70+
onPlayButtonPress.RaiseEvent(new[] {(GameSceneSO)locationSo}, showLoadScreen);
6971
}
7072
}
7173
}

0 commit comments

Comments
 (0)