Skip to content

Commit

Permalink
Update to 2.5.0
Browse files Browse the repository at this point in the history
Fixes #9
Fixes #11 and #16 by adding IgnoredFIles and IgnoredDirectories that allow you to add any file or directory to be excluded from SaveGame API, the default values are "Player.log" and "output_log.txt" for files and "Analytics" for directories
IOSupported method is now deprecated
Added UsePlayerPrefs option to allow the user to specify whether to use PlayerPrefs as storage or not (otherwise it uses file storage)
Added OnSaving and OnLoading events that occurs at the start of the processes
  • Loading branch information
hasanbayatme committed Apr 1, 2022
1 parent ff80c58 commit c934360
Show file tree
Hide file tree
Showing 11 changed files with 892 additions and 767 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine.UI;

Expand Down Expand Up @@ -32,11 +33,11 @@ public class CustomData

public CustomData()
{
score = 0;
highScore = 0;
this.score = 0;
this.highScore = 0;

// Dummy data
levels = new List<Level>() {
this.levels = new List<Level>() {
new Level ( true, false ),
new Level ( false, false ),
new Level ( false, true ),
Expand All @@ -54,35 +55,45 @@ public CustomData()

void Start()
{
if (loadOnStart)
if (this.loadOnStart)
{
Load();
}
}

public void SetScore(string score)
{
customData.score = int.Parse(score);
this.customData.score = int.Parse(score);
}

public void SetHighScore(string highScore)
{
customData.highScore = int.Parse(highScore);
this.customData.highScore = int.Parse(highScore);
}

public void Save()
{
SaveGame.Save<CustomData>(identifier, customData, SerializerDropdown.Singleton.ActiveSerializer);
SaveGame.Save<CustomData>(this.identifier, this.customData, SerializerDropdown.Singleton.ActiveSerializer);
}

public void Load()
{
customData = SaveGame.Load<CustomData>(
identifier,
this.customData = SaveGame.Load<CustomData>(
this.identifier,
new CustomData(),
SerializerDropdown.Singleton.ActiveSerializer);
scoreInputField.text = customData.score.ToString();
highScoreInputField.text = customData.highScore.ToString();
this.scoreInputField.text = this.customData.score.ToString();
this.highScoreInputField.text = this.customData.highScore.ToString();
}

public void Delete()
{
SaveGame.Delete(this.identifier);
}

public void DeleteAll()
{
SaveGame.DeleteAll();
}

}
Expand Down
Binary file not shown.
Loading

0 comments on commit c934360

Please sign in to comment.