- Home /
how to pass boolean variable into another scene without destroy it properties
hi guys, i want to pass a boolean variable from a scene into another scene. when am trying to load into previous scene the properties for the variables are destroying?
how can i avoid this?
i have already used DontDestroyOnLoad(this); but its not seems good...
is this any chance to pass variables with DontDestroyOnLoad function....?
can any one help me?
Answer by Mike 3 · Nov 08, 2010 at 12:32 PM
Use DontDestroyOnLoad(gameObject); to keep the GameObject the script is on alive
Alternatively, you could make the boolean value static, so it persists no matter whether the script is destroyed or not, but that'll stop you from being able to assign to it in the inspector
hmmm its correct mike....but i have already tried this, but the problem which i got is,the OnGUI() elements also displayed in to the next scene.(ie. all those properties got alive). thats why am asking as particularly how to make a variable as alive?
make the boolean static ins$$anonymous$$d so you can access it from any scene without even putting the script in the scene itself (ScriptName.variableName = true; etc)
Your answer

Follow this Question
Related Questions
Accessing variables on a script on a DontDestroyOnLoad GameObject 3 Answers
Prefab's Script affecting all the Prefab 1 Answer
Accessing a variable within a function.... GetComponent() 2 Answers
How to increase score for objects that form larger geometries? 0 Answers
How to rebind animated variable? 5 Answers