x


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.

more ▼

asked Mar 16 '11 at 02:47 AM

Noah 1 gravatar image

Noah 1
1.1k 33 45 50

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

1 answer: sort voted first

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.

more ▼

answered Mar 16 '11 at 02:52 AM

Joshua gravatar image

Joshua
6.5k 19 25 72

It failed, the script mut be attache to a GUITexture. Any ideas?

Mar 16 '11 at 03:03 AM Noah 1

and if you do the same but with GUITexture, attach the script to your GUITexture and add DontDestroyOnLoad

Mar 16 '11 at 03:30 AM Uriel_96

Well I am trying to make my script remember the booleans but DontDestroyOnLoad is not member of boolean.

Mar 16 '11 at 04:03 AM Noah 1

Edited answer. If it's still not clear then you have to spend a little time studying the site I linked to.

Mar 16 '11 at 01:50 PM Joshua

I am going to try the game manager. Thank you.

Mar 16 '11 at 05:05 PM Noah 1
(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:

x249
x84

asked: Mar 16 '11 at 02:47 AM

Seen: 765 times

Last Updated: Mar 16 '11 at 02:47 AM