- Home /
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.
Answer by qJake · May 11, 2010 at 10:01 PM
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.