I am trying to save a User class, but on load the reference is always null.
Is there anything else I am missing in this process?
I have a game object with this script attached:
Code: Select all
public class DataManager : MonoBehaviour
{
public User User { get; set; }
void Start()
{
if (ES3.KeyExists("FirstLoad"))
{
print("This is not the first time you have loaded this game");
User = ES3.Load<User>("User");
print(User.Username);
}
else
{
//construct save file
print("This is the first time this game has been loaded");
ES3.Save<bool>("FirstLoad", true);
ES3.Save<User>("User", new User());
}
}
}
Code: Select all
public class User
{
public int Id { get; }
public string Username { get; }
public string Gender { get; }
public int Steps { get; }
public Dog Main { get; }
public User()
{
Id = 1;
Username = "Impo";
Gender = "Male";
Steps = 0;
Main = null;
}
}
Thanks for any help