x


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?

more ▼

asked Nov 08 '10 at 11:11 AM

sriram90 gravatar image

sriram90
460 33 37 47

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Nov 08 '10 at 12:32 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

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?

Nov 08 '10 at 01:06 PM sriram90

make the boolean static instead so you can access it from any scene without even putting the script in the scene itself (ScriptName.variableName = true; etc)

Nov 08 '10 at 01:51 PM Mike 3
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x822
x82

asked: Nov 08 '10 at 11:11 AM

Seen: 1892 times

Last Updated: Nov 08 '10 at 11:11 AM