On Gui Object Click

Hey guys, i have an important question. How can i use a GUI Image as a button, so something happens on click?

1 Answer

1

public Texture textureOfButton;

void OnGUI(){

if(GUI.Button(new Rect(10,10,50,50),textureOfButton)){
 print("hi");
}

}

// drag and drop a texture on the public variable textureOfButton.
// replace print('hi") with whatever you want the button to do

Thank you!!