Remove GUI Texture

Hello,
I want a code that when I Right Click on my mouse and keep pressing it, it removes the GUI Texture. But when I stop pressing Right click, it will appear again. Thank you.

If by “keep pressing it” you mean hold it down then this should work. First you will have to “get” the GUI texture game object. To do this create a variable and then use GameObject.Find to get it.

var guiTexture : GameObject;

function Start() {

     guiTexture = GameObject.Find //(name of gui texture object); Keep the name in parentheses and with a semicolon afterwards

}

Then add the controls.

function Update() {

    if(Input.GetMouseButton(1)){

         guiTexture.active = false;

    }else

         guiTexture.active = true;

    }

Note whenever the right mouse key isn’t being pressed then the object will still show.