so Im tryint to save some data with the Unity JSON utilities but Im having some trobles.
I have a World class that inside has some parameters like Width Height etc, and a 2D array of "Tiles", that its another class
Reduced version:
public class World
{
[SerializeField]
private Tile[,] tiles;
public Tile[,] Tiles { get { return tiles; } protected set { } }
[SerializeField]
private int width;
public int Width
{
get { return width; }
}
[SerializeField]
private int height;
public int Height
{
get { return height; }
}
public int WorldSize
{
get
{
return height * width;
}
}
}
And in another script I have the save system, currently Im trying to save this world with its tiles:
public void SaveWorld(World worldToSave)
{
SaveSystem.Init();
string json = JsonUtility.ToJson(worldToSave);
Debug.Log("Json es: " + json);
//AHORA MISMO ESTO GUARDA SOLO WIDTH Y HEIGHT DEL MUNDO
File.WriteAllText(SaveSystem.SAVE_FOLDER + "/Save.txt", json);
}
Tiles are already with Serializable, and if I make an 1D array I can save them and get data from them, but I dont know how to do it with 2D or how could I change it (its 2D because I get them with X and Y coordinates).
Also, I dont really undestand how JSON wraps this tiles inside the world, and things inside the tiles and so on.


