- Home /
 
 
               Question by 
               Pixelen · Jan 08, 2012 at 02:46 PM · 
                guitextureactivehideshow  
              
 
              Show/hide GUI texture
Hi, I've got a problem with showing and hiding GUI textures. When I click a button I want it to hide and a different one to show. On the original button I have this code:
 function OnMouseDown() {
    gameObject.active=false;
    gameObject.Find("EasyButton").SendMessage("Show");    
 }
 
               And on the other button I have this code:
 function Show() {
        gameObject.active=true;      
 }
 
               Can anyone tell me where I'm going wrong?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by aldonaletto · Jan 08, 2012 at 11:16 PM
You can't find an inactive object with Find, and even if you could, I suspect that it would not answer to SendMessage.
 If you're using GUITexture, disable/enable the textures with guiTexture.enabled instead:
function OnMouseDown() {
   guiTexture = false; // or use "gameObject.active=false;" as before
   gameObject.Find("EasyButton").guiTexture.enabled = true;   
}
 You don't need the other button's script in this case. 
              Answer by tatelax · Jan 08, 2012 at 10:39 PM
Use something like this:
 var showButton = false;
 
 function OnMouseDown() {
      var button = gameObject.Find("EasyButton");
 
      if (showButton) {
         button.active = true;  
      }
 }
 
              Your answer