Hello, I have been working on my first game for some time now and have hit a bit of a wall with saving, I’ve been trying to find out how to get my saved variables to actually save, they seem to work just fine going between different scenes, but not so much when it comes to actually closing the game and re-opening it. I’ve heard a bit of mention about this “Save Variables” node, which I have appended to a save script that runs every time the menu scene is entered. This is the script :
Every other script that I have that uses the set saved variable node does not have the save variables in them.
Hello.
Please add some logs in graph, and more details about the UVS version you are using.
As you can see, in first run the log shows the initial value, and in the second run the log shows the saved value.
Why do you say is not working for you?
It seems to work just fine when I switch between scenes, but it doesn’t save if I exit the program.
On Start triggers when you enter the scene once, it does not trigger on application exit. Just save the variables On Application Quit event.
Gave it a shot, still doesn’t quite seem to work
Perhaps also try OnDisable or OnDestroy. Maybe saved vars system is incompatible with On App Quit event since objects get disabled and destroyed on app quit.
You could also try delaying the flow in Start. Perhaps there’s some issue with execution order, so delaying the flow by a frame could solve that.
Assuming none of the above works, my guess would be that you’re setting the saved variables elsewhere in the initial start scene.
Just found this in the console
PlayerPrefs have very limited type support. Generally string, ints and floats are only accepted. Are you trying to save some other type?
hmmm, are lists of bools accepted?
Just figured it out, it was a list of materials that was causing the issue, thank you very much sir!
Hello. I’m facing a similar problem. I use additive scene loading.
So that the player does not look at the frozen screen when loading the next heavy scene - I load the loader scene to transition between the main scenes, which contains only one scenario - it additively loads the next scene, while showing animation. When the scene is ready to run, I perform Allow scene activation.
If the player EXITS the game at the moment of additive loading of the scene, VS does not record the saved variables. And when you first start the game the next time - VS uses the saved variables from the moment when it was able to be overwritten. Sometimes it throws the player back several levels!
I think the problem is that at the moment the player exits the game - there are two scenes in the game at once (one is a loader, the second is loaded additively) - and VS does not know how to save variables correctly and does not do it.
The main question. How to FORCE save variables from time to time?
“On application quit, pause” and next- player.prefs save variables d’ont work
!!!
I’m very sorry.
The “save variables” node solved all my problems!
I didn’t know about its existence and tried to write down every saved variable forcibly - but it didn’t help.
By adding this node, everything began to be recorded!
Just in case, I put the script in “dont destroy on load”