Show image when a GUI button is pressed [problem]

Hi… I’ve created this script for show/hide an image when a button is pressed, but in play mode I don’t see the image, and I cannot set its values… Any ideas?

#pragma strict

import System.Collections.Generic;
var buttonstyle : GUISkin ;

var texture : Texture;
var mostra : boolean;
var on : boolean;

var texWidth : float; // texture width
var texHeight : float; // texture height
var texpositionx : float;
var texpositiony : float;

function OnGUI (){

GUI.skin  = buttonstyle;
if(GUI.Button(new Rect(808,9,35,34),"")){
GUI.DrawTexture(new Rect(Screen.width / texWidth,  Screen.height / texHeight, texpositionx, texpositiony),texture);

on = !on;

if (!on){
mostra = true;
}

if (on){
mostra = true;
}
}
}

Is there a particular reason why you’re using instant GUI and not the Canvas-based uGUI?

uGUI is way handier and what you’re trying to do wouldn’t even need a script. It’s ready. UI Button Tutorial

I didn’t fully understand you script but, i think there is a mistake here:

 if (!on){
 mostra = true;
 }
 
 if (on){
 mostra = true;
 }

You assing true for both conditions.