- Home /
Question by
Babilinski · Nov 05, 2011 at 01:21 AM ·
guitextureenablec
Activating GUI
I want a GUI texture to appear in the center of the screen when i pressed shift, i looked all over but i didn't find anything please help.
Comment
Best Answer
Answer by vivalarosa · Nov 05, 2011 at 02:25 AM
All you have to do is set the GUI texture turned off to begin, by checking the box on the GUI Texture component. Add this script to the gameobject it's attached to.
if (Input.GetKey (KeyCode.LeftShift))
{
GUITexture.enabled = true;
}
if (Input.GetKeyUp (KeyCode.LeftShift))
{
GUITexture.enabled = false;
}
See how that goes, tell me if you have troubles
Answer by aldonaletto · Nov 05, 2011 at 02:27 AM
It's easy - attach this script to the GUITexture:
function Update(){ guiTexture.enabled = Input.GetKey("left shift"); }If you need to check both shifts, use
guiTexture.enabled = Input.GetKey("left shift") || Input.GetKey("right shift");