Changing GUIStyle background texture?

How to change GUIStyle normal background texture2D through script?

This will be used whenever I clicked a button the background texture2D will be changed its texture2D.

In the Scripting Reference, it says use this code:

    //i just add a gui.button
    var aTexture : Texture2D;
    if (GUI.Button (Rect (590,244,150,50), chap)){
        GUI.skin.customStyles[0].active.background = aTexture;
    }

but it is not working for me …
any suggestions?? thanks in advance :slight_smile:

Just try this…

declaration –

var texture1:GUIStyle;

var texture1 : GUIstyle;

var defaulttexture: GUIStyle;

if(GUI.Button(),“Login”,defaulttexture); // assign default texture here.
{

if(var bool==true)

{

defaulttexture = texture1;

bool=false

}

else

{

defaulttexture = texture2; // here use the default texture.

}

}