So i’m trying to generate level geometry simply by using Line Renderer and Edge Collider 2D. The level data is stored inside json file and looks like this:
[
{
"id": 0,
"title": "Some level",
"spawnPoint": [0, 5],
"finishPoint": 30,
"xPoses": [0, 10, 20, 30],
"yPoses": [0, 5, 10, 15]
}
]
There is nothing wrong with reading single variables until it comes to arrays. I can’t figure out how is it done in LitJson. In my project I have the Level class which looks like this:
public class Level {
public int id { get; set; }
public string title { get; set; }
public int[] spawnPoint { get; set; }
public int[] finishPoint { get; set; }
public float[] xPoses { get; set; }
public float[] yPoses { get; set; }
}
Levels are stored inside the List object and I load them like this
levelData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/StreamingAssets/Levels/levels.json"));
private List<Level> levelDatabase = new List<Level>();
So the main question is how to read a JSON array (spawnpoint, x/y Poses) and make it into the C# one.
Thank you.