#How get varibles form other scenes into one scene
1 messages · Page 1 of 1 (latest)
Generally, there's 3 ways of making variables persist between scenes:
- Place the script containing the variable(s) on a DontDestroyOnLoad object
- Make the variable(s)
static - Store the variable(s) on a
ScriptableObject
You can use playerprefs
PlayerPrefs are very limited in what they can store.
They also are meant to hold preferences, not game data.
And on top of that, they are not supposed to be used for caching, but for storing persistent values.
Does static variables value reset after closing the game?
Yes they do.
- Does that actually work on builds? as far as I know,
SrciptableObjects can only be used to store values in editor, not runtime on builded game
This was about transferring values between scenes - not storing them persistently. ScriptableObjects will indeed get reset when the game is closed, even if they do keep values after exiting play mode in the editor.
Some unity answers solutions suggest that they don't even persist between scenes (on build) but I haven't tried that myself so I don't really know