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 ![]()
#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);
}
}