HELP!! texture button

need some help!! swap texture button

hey guys

i am new in unity scripting and i am i little lost in this code, i dont know why doesnt work,
I have a button. I want it to switch textures when it’s clicked

i have this code
function Start () {

}

var piso : GameObject;
var texture : Texture2D;
var texture2 : Texture2D;
var myguiSkin :GUISkin;

function OnGUI () {

GUI.skin = myguiSkin;

GUI.BeginGroup (Rect (10, 10, 800, 250));

GUI.Box (Rect (0,0,150,250), “select texture” );
if (GUI.Button (Rect (10,40,120,80), texture)){
piso.renderer.material.mainTexture = texture;
}
if (GUI.Button (Rect (10,120,120,80), texture2)) {
piso.renderer.material.mainTexture = texture2;
}
GUI.EndGroup ();

}

I dont know if my code is wrong or the process that I use, any help i will appreciate
thanks
Note: attached the file

https://mega.co.nz/#!dcMzDCTQ!Ycc7B9xC0FVHI2wCylx7Wo8bUiMve4ZoLqRCc-S1V0I

would like to help but the file you linked asks
Enter decryption key

This is your code from the post

function Start () {

}

var piso : GameObject;
var textura : Texture2D;
var textura2 : Texture2D;
var myguiSkin :GUISkin;


function OnGUI () {



GUI.skin = myguiSkin;

GUI.BeginGroup (Rect (10, 10, 800, 250));

GUI.Box (Rect (0,0,150,250), "selecciona textura" );
if (GUI.Button (Rect (10,40,120,80), textura)){
piso.renderer.material.mainTexture = icon;
}
if (GUI.Button (Rect (10,120,120,80), textura2)) {
piso.renderer.material.mainTexture = textura2;
}
GUI.EndGroup ();

}

Anyway it does work if you change icon on line 21 to textura

hi softwizz, i change icon with texture, but still not working, I fixed the link https://mega.co.nz/#!dcMzDCTQ!Ycc7B9xC0FVHI2wCylx7Wo8bUiMve4ZoLqRCc-S1V0I would appreciate if you saw and give me your opinion

Hey, i just tested your code and it works fine. Like SoftWizz said, just replace icon with textura.

On your script you need to drag the floor object from the Hierarchy and not the project.
1497215--84061--$change_texture.png

OMG…WORKS!!! thank you soo much softwizz i cant believe i got stuck for days on that
thnks again
seeya