I'm trying to get my head around using JSON files to store level data . Specifically in this example is to make my walls. (its a top-down game like pacman). Each wall prefab is a 1x1x1 cube. I just want the JSON to hold the x,y,z. I have seen tutorials about how best to deserialise the data into Unity and I think im fine doing that, but I am unsure of how exactly to word the JSON file.
I see the example on Unity docs says the format is like this:
{"level":1,"timeElapsed":47.5,"playerName":"Dr Charles Francis"}
so, I could just do something like:
{"index":0,"x":5,"y":1,"z":0}
but I know that there needs to be a bit above, similar to XML and of this im clueless of what it needs to contain.
I looked on Json.org but i didnt really understand it still. This is one example:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
But what is 'Glossary' and 'title' in the context of my game? All I currently have is a cube called Wall, with a script attached called Wall.cs that currently does nothing, but I will be making an array of Wall and plan on using the deserialised data from the json file to lay the Walls[] out using my GameController.cs
Once I know what to put above and below to open and close the JSON file off, im pretty sure I can get it working how I need it to. I hope that made some sense.