How do I show GUI texture when I click an Object and hide it with another click?

Hi,

I’m creating an educational project and I need when I click on GameOpject to Show GUI texture “contains some information” and freeze all controls and movement for the first person until the next click “anywhere” to resume everything and hide GUI texture.

I used this Script :

#pragma strict
 
var diary : GUITexture;
 
function Start (){
    diary.enabled=false;
}
 
function OnMouseDown() {
    diary.enabled=true;
}
 
function OnMouseUp() {
 
    diary.enabled=false;
}

From here:
Thanks to robertbu

It’s useful but it’s not enough for me,

Sorry I’m not programmer and I need your help

Toggle the state each time you click it.

dairy.enabled = !dairy.enabled;

The exclamation sign (!) is a logical negation operand and returns false if the value right of it is true, and returns true if the value right of it is false.

  • If dairy.enabled is true, set dairy.enabled to false.
  • If dairy.enabled is false, set dairy.enabled to true.

Read more on MSDN.