I am having problems with saving and loading when I go back and forth between scenes.
So, I have a player object, and I have created code to save and load his level, health and location when I hit the save or load buttons. I also have it set to DontDestroyOnLoad so when I switch scenes I don't lose it's information. I have 2 scenes currently, and in the first scene I can move it around and increment its health and level and then hit save and it saves it perfectly fine and I can load it perfectly fine. I can then switch to my other scene which is my main menu and my player doesn't get destroyed like I had intended. I can then switch back to my first scene and my player loads in fine, because it was not destroyed. My problem is that once I switch back to my first scene save and load won't work.
Answer by VIPINSIRWANI · Feb 13, 2019 at 10:42 AM
If you are not destroying your player only because of data lose. Then it will be good to use PlayPref for saving and loading data.
So may you can look into below link like how to save and load data from PlayPref.
https://forum.unity.com/threads/example-of-using-player-prefs-to-save-and-get-a-variable.42398/
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
Hope this will help you.
if he uses playerprefs for saving health location or level, for example, his game would be really easy "hackable", also he is not asking for a way of saving / loading since he says is working already, but why is not working on scene change.
Thanks! I just took the do no destroy on load off for now and made it auto save between scenes for now.