How do you Set a PNG to a GUI Button?

I’ve tried all the ways I could find but I don’t know how it works.

I’m making a button that when it is held down a timer counts up and when you let it go it stops the timer. Right now I have a normal rectangular button but I’d like to have a round button. I’ve been able to get the PNG image IN the button where the text would go. But I haven’t been able to make the image itself the button :frowning:

#pragma strict

//Sorry for the Messy Code.

var counter: int = 0; 
var Timer = 0.0;
var gameText: GUIText;
var btnTexture:Texture;

function Start(){ 
	gameText = gameObject.GetComponent(GUIText); 
}
function OnGUI () {
    GUI.Box (Rect (20,20,100,90), "Hold IT"); 
    if (GUI.RepeatButton(new Rect(20,40,80,20), btnTexture)) {
	counter++;
	Timer += Time.deltaTime;
	var hours : int =  Timer / 3600;
    var minutes : int = Timer / 60;
    var seconds : int = Timer % 60;
    var fraction : int = (Timer * 100) % 100;
	gameText.text = String.Format ("{0:00}:{1:00}:{2:00}:{3:00}", hours, minutes, seconds, fraction); 
	
       
    } 
  }

In your assets folder in your project create GUIStyle. In it it is necessary to change “normal background” to that picture which is available for you. Further to make a reference to your new style. Code see below:

 #pragma strict

 var counter: int = 0; 
 var Timer = 0.0;
 var gameText: GUIText;

 var btnStyle:GUIStyle; //reference on your style

 function Start(){ 
  gameText = gameObject.GetComponent(GUIText); 
 }

 function OnGUI () {
  GUI.Box (Rect (20,20,100,90), "Hold IT"); 
  if (GUI.RepeatButton(new Rect(20,40,80,20), "", btnStyle)) { //apply your style
   counter++;
   Timer += Time.deltaTime;
   var hours : int =  Timer / 3600;
   var minutes : int = Timer / 60;
   var seconds : int = Timer % 60;
   var fraction : int = (Timer * 100) % 100;
   gameText.text = String.Format ("{0:00}:{1:00}:{2:00}:{3:00}", hours, minutes, seconds, fraction); 
  } 
 }  

I hope that it will help you.