I was following the brackeys tutorial on saving and loading
and i got this error and have been fiddling with it for the past hour and can’t seem to fix it
Assets/SaveSystem.cs(20,19): error CS0246: The type or namespace name ‘PlayerData’ could not be found (are you missing a using directive or an assembly reference?)
I have no clue what is wrong with my code!
(My Code)
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class SaveSystem{
public static void SavePlayer(PlayerMovement Player)
{
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/player.playermonoscript.binaryconvert";
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 + "/player.playermonoscript.binaryconvert";
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;
}
}
}