How do I access public variables that are in other scenes?
2 Answers
2Here are the usual options for storing persistent data between scenes:
- Static variables
- DontDestroyOnLoad()
- PlayerPrefs
- A custom save/load system
You can't access a public variable of object X in scene B from scene A because object X does not exist at that point. Depending on what you need though, you should be able to use one of the aforementioned methods to do whatever it is you're wanting to do.
Tyler try to look into "SendMessageUpwards" function. I've done before but just forgot the details. Roughly what I did was, having a script with a function that receives data from whoever calls it through "SendMessageUpwards". hopefully that works you.