Saving all prefab positions in one JSON file
I'm trying to save all the trees in my scene (which are not procedurally generated) as well as player data and other things like events into a single editable JSON file. Currently, I'm achieving this by creating a "Tree Save" component which gets the position and type of tree it is placed on when the player chooses to save the game, and returns it to write into the JSON file.
var treeList = FindObjectsOfType<SaveTree>();
foreach (SaveTree tree in treeList)
{
tree.SaveTreeData();
}
gameData.trees = treeList;
string jsonData = JsonUtility.ToJson(gameData);
File.WriteAllText(path, jsonData);
However, in this way, my JSON file is a collection of "instance IDs" instead of editable positions, and the like. How do I make it so that I can save each tree's position and type (and in the future, player data) into a single, editable JSON file? Thanks.
Comment