x


How to get a list of all the GUI elements in a scene?

I would like to know how to get a list of all the GUI elements in a scene and disable them (make them invisible).

Thanks in advance

more ▼

asked Nov 20 '11 at 04:50 PM

noelrocha gravatar image

noelrocha
1 2 2 3

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

1 answer: sort voted first

You can make all GUI controls invisible by not drawing them.

This can be done using a boolean to track whether or not the GUI should be drawn. If it is false, have your scripts either exit the OnGUI function immediately or not draw certain controls.

I'm not sure there is a way to get a list of all the GUI controls in a scene. I'm don't know if that makes sense given the way Unity approaches its GUI system. Based on the way the controls are drawn from frame to frame, I'm not sure a list of this kind is maintained.

That being said, the state of Toggle buttons is obviously mainained, so maybe there is such a list. If there is such a thing, it should be in the documentation somewhere.

more ▼

answered Nov 20 '11 at 09:12 PM

jahroy gravatar image

jahroy
3.2k 14 18 41

Thats what Im trying to find. Some documentation about this possible list. :(

Nov 20 '11 at 09:26 PM noelrocha

I don't believe it exists.

Since each control is drawn explicity by you, the programmer, it's probably up to you to build and maintain this list as you draw them.

It's not like you create them and give them names. They're drawn BY YOU every frame.

Nov 20 '11 at 09:30 PM jahroy

I'm using a third part plugin. In that plugin, there is a info button that calls another scene that you put informations about your game. But my client doesn't want to create a new scene to include informations about the game in this way. So I want to make this button invisible. Thats why I want to get a list of the GUI elements and disable this one.

Nov 20 '11 at 09:34 PM noelrocha

No clue how to deal with this mysterious plugin of yours...

Ideally you can look at and/or alter its source code. If not you may be out of luck.

Maybe you could draw something of your own over the button as a workaround.

Nov 20 '11 at 10:49 PM jahroy
(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:

x3690
x356
x215
x13

asked: Nov 20 '11 at 04:50 PM

Seen: 750 times

Last Updated: Nov 20 '11 at 10:50 PM