¿¡ HoW to add a timer into game screen ?!
Here’s a tutorial on many types of HUD elements. Jump down to Step 13 for the timer.
Here is a timer that counts upwards in seconds:
var seconds : int;
function Start () {
seconds = 0;
InvokeRepeating("Count", 0, 1);
}
function Count () {
seconds += 1;
}
var native_width : float = 1920;
var native_height : float = 1080;
function OnGUI () {
var rx : float = Screen.width / native_width;
var ry : float = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1));
GUI.skin = customSkin;
GUI.Label(Rect(10, 10, 400, 300), "Time: " + seconds.ToString());
}