- Home /
 
               Question by 
               Uninity · Nov 05, 2012 at 01:13 PM · 
                guiinputguitexturekey  
              
 
              GUITexture KeyInput
Hey, I want a GUI Texture to enable and disable when I press the B Key. Is this possible?
               Comment
              
 
               
              Answer by Griffo · Nov 05, 2012 at 01:36 PM
Try this
 var guiTexture : Texture2D;    // The GUI texture to use
 private var z : int;
 private var guiTrue : boolean;
 
 function Update () {
 
 if (Input.GetKeyDown ("b")){
     z = (z % 2) + 1;
     if(z == 1){
     guiTrue=true;
         }else{
         guiTrue=false;
         print(z + " False");
         }
     }
 }
 
 function OnGUI()
 {
         if(guiTrue){
         GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), guiTexture);
         print(z + " True");
     }
 }
Sorry missed out
 private var z : int;
at the top, amended answer.
Doesnt work unfortunately, I drag the script onto the GUITexture if that's the correct thing to do.
No, thats not correct, I've amended the script again, drag a texture onto the guiTexture in the inspector, then when you press "b" it will fill the screen with that texture.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                