Storing levels data as json?
Hi there, i have more than 100 levels. all levels have their own data like candy crush game. i want store all the data in a single file. to modify and read.
Heare is bit of code i have.
public class DataManager : MonoBehaviour {
public List <Level> GameData = new List<Level> ();
void Awake(){
PushDefaultData ();
}
void PushDefaultData(){
for (int i = 0; i < GameData.Count; i++) {
GameData [i].lvlNo = i + 1;
GameData [i].startsCount = 0;
if(i == 0)
GameData [i].isLevelLocked = false;
else
GameData [i].isLevelLocked = true;
GameData [i].score = 0;
GameData [i].bestMoves = 0;
}
}
}
[Serializable]
public class Level{
public int lvlNo;
public int startsCount;
public bool isLevelLocked;
public int score;
public int bestMoves;
}
There is unity example to convert class into json. but i didn't find any way to convert that list of classed into json.
now my how can i convert the list of classes into a json file.
thanks
Your answer
Follow this Question
Related Questions
Using ScriptableObjects for a Pokemon-like RPG 0 Answers
Scriptable object only save change on Exit 1 Answer
Keep data created at runtime in ScriptableObjects? 1 Answer
Saving reference to a ScriptableObject with JsonUtility 1 Answer
How to save class data(variables) into an asset file in editor ? 1 Answer