- Home /
How to remember a boolean?
Hey guys I created some booleans, if theyre setted to true the will unlock the other levels. The problem is that when I change the scene and come back the are setted to false again.
Any ideas on how to keep them in true once I complete the level?
I need to make the variable remember the event.
Answer by Joshua · Mar 16, 2011 at 02:52 AM
Attach the script to an empty gameObject and add DontDestroyOnLoad would do the trick.
Edit for further explanation:
Your script already 'remembers' values you feed to it, it's just that the script gets destroyed when you load a new scene. I take it you already have the script attached to something in your scene, now when you add DontDestroyOnLoad to this script it will 'survive' scenechanges.
It failed, the script mut be attache to a GUITexture. Any ideas?
and if you do the same but with GUITexture, attach the script to your GUITexture and add DontDestroyOnLoad
Well I am trying to make my script remember the booleans but DontDestroyOnLoad is not member of boolean.
Edited answer. If it's still not clear then you have to spend a little time studying the site I linked to.
Your answer
![](https://koobas.hobune.stream/wayback/20220613113111im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Update collisions 1 Answer
Should I use == to compare boolean in an if statement? 1 Answer
How do I check a boolean from another script in C#? 0 Answers
How would I use Mecanim to holster or draw a weapon? (C#) 1 Answer
Pause Button Help 2 Answers