x


Help with cameras and enabling/disabling GUItextures?

My scene begins with begins with two GUItextures being displayed. I made them by selecting GameObject>create other>GUITexture. I would like these to disappear and reappear at different times during the scene but failing to figure it out.

I have statements set up in my camera script to call different events; I'm just very confused as to how I can simply tell the GUITextures to enable/disable from it.

Any help is appreciated.

more ▼

asked May 11 '10 at 09:46 PM

Rick 1 gravatar image

Rick 1
21 2 2 6

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

1 answer: sort voted first

First off, you need to get a reference to the GUITexture's game objects. You can do this in one of several ways:

  • Find the object by name
  • Find the object by tag
  • Store a reference to the object in your camera script using the Inspector, and a public variable.

Assuming you have the reference to the game object(s) containing the GUITexture, turning it on and off is relatively easy.

// C#

// GameObject myObject;
// Get a reference to the game object that stores the GUITexture somehow.

GUITexture gt = myObject.GetComponent(typeof(GUITexture)) as GUITexture;
gt.enabled = false;

Once you have the component reference, just set enabled to false, and it'll stop whatever it's doing immediately.

more ▼

answered May 11 '10 at 10:01 PM

qJake gravatar image

qJake
11.6k 43 78 161

(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:

x3816
x3132
x2279

asked: May 11 '10 at 09:46 PM

Seen: 3248 times

Last Updated: May 11 '10 at 09:46 PM