Files in enum Platforms are MonoBehaviour scripts that are serialized to json format for saving. Your save file must inherit from SaveFile.cs to work with enum Platforms.

ex: Custom serializable save file script

using enumGames.Platforms;

public class GameSaveFile : SaveFile
{
	public string CustomGameName;
	public int coins = 99;
	public int livesRemaining = 5;
}

Code Sample - LoadOrCreate()

Call LoadOrCreate() to load a save file. If the file does not exist, it will be created

public static void LoadMainSaveFile(PlatformPlayer player)
{
	player.LoadOrCreateFile("MainSave", typeof(GameSaveFile), (file, result) =>
	{
		if(result == PlatformPlayer.FileResult.Success)
    {
			Debug.Log("Successfully loaded file!");
    }
    else
    {
			Debug.Log("Failed to load file with result: " + result.ToString());
		}
	});
}

Flowchart - Load or Create

LoadOrCreateFile.drawio.png

Code Sample - SaveFile()

Call Save to save a file. A file must be loaded first via LoadOrCreate()

public static void SaveFile(PlatformPlayer player, SaveFile file)
{
	player.SaveFile(file, (file, result) =>
	{
		if(result == PlatformPlayer.FileResult.Success)
    {
			Debug.Log("Successfully saved file!");
    }
    else
    {
			Debug.Log("Failed to save file with result: " + result.ToString());
    }
	});
}

Flowchart - Save File

SaveFile.drawio (2).png

Code Sample - Delete()

Call to delete a file

public static void DeleteFile(PlatformPlayer player, SaveFile file)
{
	player.DeleteFile(file, (file, result) =>
	{
		if (result == PlatformPlayer.FileResult.Success)
		{
			Debug.Log("Successfully deleted file!");
		}
    else
    {
			Debug.Log("Failed to delete file: " + result.ToString());
    }
	});
}

Flowchart - Delete File

Deleting a file using the file object as parameter validates the object was first loaded through the player. You may also delete files using file name - this will not require the file to be loaded first.