Changing box texture

Hi I have a gui button and I want to change the texture inside it to a certain texture that i have as an asset. here the code that I did not find how to work:

function OnGUI () {

 
	GUI.Button(new Rect (0,0,100,50), "Button Text", image1); // image1 is the name of the texture
	

}

Another question, is it possible to have 4 textures layered one on top of the other? (They have alpha so would blend)

var image1 : Texture; // drag here in the inspector

function OnGUI () {
    // rest of code

If you put 4 labels on top of each other, they would be layered. You could also use GUI.color.a set to some kind of transparency instead of having it be in the texture.

–Eric

Create a custom GUIStyle and use that. It’s how I’ve made all the menu buttons and some of the dialog backgrounds in my game.

public GUISkin skin;

if(GUILayout.Button("",skin.GetStyle("exit")))
{
    Application.Quit();
}

Hi. Every answer I see say this: drag and drop the texture… I need it to be 100% script… Sorry for not saying it properly

For my project i can’t use a custom gui style. It has to be made dynamically.
Any idea on how to just load a texture from my assets onto my button?