ApplyData data is null and GameObjects are not loading
Posted: Sun Feb 20, 2022 5:29 pm
Hello
I ran into a weird issue while restructuring my scene hierarchy.
I am using VS Code with Unity Debugger. My Unity version is 2021.1.17f1 and Dialogue System version is 2.2.18.
I start the game on StartScene, where I have my Dialogue Manager with Menu System and Save System (with PlayerPrefs Saved Game Data Storer).
I start my game and by pressing "Start" I load scene "Player" which acts as a persistent scene in my game, holding the player, camera, lights, and inventory in it.
I then additively load an environment scene based on what needs to be loaded.
When I start my game and pick up some items, they are added to the inventory well ok.
I tried debugging the ApplyData(string data) method inside the saver, and it seems the "data" string is null. I am not proficcient enough in C# to know if this means that the string is actually empty or the debugger just doesn't see it.
If I go back in the call stack, the Apply Data is called from SaveSystem with what looks like to be the proper SavedGameData
This is puzzling me, why is the data null all of a sudden?
I had the saving/loading working, but I had to refactor some stuff and decided to add the Menu System and Save System that are available on this site.
I ran into a weird issue while restructuring my scene hierarchy.
I am using VS Code with Unity Debugger. My Unity version is 2021.1.17f1 and Dialogue System version is 2.2.18.
I start the game on StartScene, where I have my Dialogue Manager with Menu System and Save System (with PlayerPrefs Saved Game Data Storer).
I start my game and by pressing "Start" I load scene "Player" which acts as a persistent scene in my game, holding the player, camera, lights, and inventory in it.
I then additively load an environment scene based on what needs to be loaded.
When I start my game and pick up some items, they are added to the inventory well ok.
When I save a game, all data seems to be saved properlyInventory inventory = GetComponent<Inventory>();
return SaveSystem.Serialize(inventory);
But when I try loading the game my Inventory GameObject does not get the data. There is only one Intenvory present in the game.SavedGame1: {"m_sceneName":"Player","m_list":[{"key":"AlfonsoPosition","sceneIndex":1,"data":"{\"scene\":5,\"position\":{\"x\":874.1185913085938,\"y\":83.27227783203125,\"z\":-2190.5478515625},\"rotation\":{\"x\":0.0,\"y\":0.266330748796463,\"z\":0.0,\"w\":0.9638817310333252}}"},{"key":"Main Camera","sceneIndex":-1,"data":"{\"scene\":5,\"position\":{\"x\":871.164306640625,\"y\":85.48347473144531,\"z\":-2195.871337890625},\"rotation\":{\"x\":0.05638600513339043,\"y\":0.2501929700374603,\"z\":-0.014597225934267044,\"w\":0.9664424657821655}}"},{"key":"AdditiveSceneManager","sceneIndex":1,"data":"{\"Alfonso\":{\"instanceID\":2032734},\"Airplane\":{\"instanceID\":2032756},\"mainCamera\":{\"instanceID\":2018174},\"playerCam\":{\"instanceID\":2027974},\"BlackFade\":{\"instanceID\":2021468},\"circleTransitionController\":{\"instanceID\":0}}"},{"key":"AddedScenes","sceneIndex":1,"data":"{}"},{"key":"PlayerInventory","sceneIndex":1,"data":"{\"activeBody\":{\"instanceID\":62272},\"activeFront\":{\"instanceID\":0},\"activeTail\":{\"instanceID\":0},\"activeWings\":{\"instanceID\":0},\"activeWheels\":{\"instanceID\":0},\"activePropeller\":{\"instanceID\":0},\"activeMotor\":{\"instanceID\":0},\"items\":[],\"planeParts\":[{\"instanceID\":62260},{\"instanceID\":62262},{\"instanceID\":62264},{\"instanceID\":62266},{\"instanceID\":62268},{\"instanceID\":62270},{\"instanceID\":62272},{\"instanceID\":62274},{\"instanceID\":62276},{\"instanceID\":62278},{\"instanceID\":62280},{\"instanceID\":62282},{\"instanceID\":62284},{\"instanceID\":62286}]}"}]}
I tried debugging the ApplyData(string data) method inside the saver, and it seems the "data" string is null. I am not proficcient enough in C# to know if this means that the string is actually empty or the debugger just doesn't see it.
If I go back in the call stack, the Apply Data is called from SaveSystem with what looks like to be the proper SavedGameData
This is puzzling me, why is the data null all of a sudden?
I had the saving/loading working, but I had to refactor some stuff and decided to add the Menu System and Save System that are available on this site.