Hi,
My game is having several scenes and now, i want to read a value from one scene’s script to another scene’s script.
Is this possible???
If yes, then can any one please tell me how to make it.
Note: I got accessing the variables with in the same scene but that is not happening if the scene is changing…
I think you need to use the DontDestroyOnLoad method so the GameObject you have the scripts attached to can persist across scene changes.
Methods for handling data that should persist between scenes include (but aren’t necessarily limited to):
-
Associating the data with an object that’s made persistent using DontDestroyOnLoad()
-
Using static variables to store the data
-
Using PlayerPrefs (which will also cause the data to persist between runs of the application)