I was trying to make a save and load system and everything is set up but when I press the save button I get these two errors:
and
Here is my code:
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class SaveSystem
{
public static void SavePlayer (Player player) {
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/save.arbf";
FileStream stream = new FileStream(path, FileMode.Create);
PlayerData data = new PlayerData(player);
formatter.Serialize(stream, data);
stream.Close();
}
public static PlayerData LoadPlayer ()
{
string path = Application.persistentDataPath + "/save.arbf";
if(File.Exists(path))
{
BinaryFormatter formatter = new BinaryFormatter();
FileStream stream = new FileStream(path, FileMode.Open);
PlayerData data = formatter.Deserialize(stream) as PlayerData;
stream.Close();
return data;
} else
{
Debug.LogError("Save file not found in " + path);
return null;
}
}
}