- Home /
Question by
SultanZabu · Sep 29, 2013 at 12:05 PM ·
json
Custom Class JSON Serialization
I have a gamestate class that I made completely serializable. However, I want to convert ONLY an instance of this class to json and save it to local storage. I've looked through a couple packages and they all seem to do to much.
so, all I want is just to save this simple class to json. And preferably with no 3rd party packages.
[System.Serializable]
public class GameState {
public float taxRate = 1;
public float might = 0;
public float unrest = 0;
public int money = 180;
public int day = 1;
public float difficulty = 0.5f;
public float spawnRate = 0.1f;
public string currentScene;
public bool inaugurated = false;
public float birthRate = 0.1f;
public float interestRate = 0.5f;
[SerializeField]
public List<Citizen>[,] people = new List<Citizen>[3,3];
[SerializeField]
public List<Badge> force = new List<Badge>();
[SerializeField]
public List<Occurance> occurances = new List<Occurance>();
[SerializeField]
public List<Story> news = new List<Story>();
}
Comment
Best Answer
Answer by PuneetK · Sep 29, 2013 at 12:38 PM
I don't think unity supports LocalStorage, you'll have to use an Array of PlayerPrefs.
Your answer