I'm working on a save and load system for my game in Unity3D. The basics like position is simple, I just have
public void Save() {
PlayerPrefs.SetFloat ("X", transform.position.x);
PlayerPrefs.SetFloat ("Y", transform.position.y);
PlayerPrefs.SetFloat ("Z", transform.position.z);
}
public void Load() {
float x = PlayerPrefs.GetFloat ("X");
float y = PlayerPrefs.GetFloat ("Y");
float z = PlayerPrefs.GetFloat ("Z");
transform.position = new Vector3 (x, y, z);
}
But then comes the part when I want to save custom variables. Here's how the class that contains them looks like:
[SerializeField] private Stat health;
public static Stat Health { get; set; }
[SerializeField] private Stat exp;
public static Stat Exp { get; set; }
[SerializeField] private Stat oxygen;
public static Stat Oxygen { get; set; }
[SerializeField] private Stat playerLevel;
public static Stat PlayerLevel { get; set; }
So my question is, how do I get values of those stats in my SaveLoad script?