x


Onscreen Timers

Hi I'd like to make 2 timers to show on screen. (preferably in Java) They all need to yeild 8 for seconds before starting.

I'd like a 3, 2, 1, go - timer and a Countdown timer.

I've been trying with lots of different bit I could find, and nothing is working :(

Thanks

more ▼

asked Mar 08 '12 at 12:16 AM

LittleCat1 gravatar image

LittleCat1
37 5 14 17

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Here is a link to a basic timer. http://www.youtube.com/watch?v=aHf96fBBYM0 To show them you can do something with OnGUI().

function OnGUI()
{
    GUI.TextArea(myRect,timerVarToShow);
}

Make sure to utilize the unity ref for specific functions, vars, overloads, and anything else. Hope this helps, Happy coding!

more ▼

answered Mar 08 '12 at 12:43 AM

hijinxbassist gravatar image

hijinxbassist
2k 23 31 38

Forgot to add, since the timer var will be a float and you most likely want to show the whole number, add Mathf.CeilToInt which will display the number rounded up to a whole(10.2 becomes 11). There is also Mathf.FloorToInt which rounds down(10.2 becomes 10).

Ex

function OnGUI()
{
    GUI.TextArea(myRect,Mathf.CeilToInt(timerVarToShow));
}
Mar 08 '12 at 02:04 AM hijinxbassist
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x349

asked: Mar 08 '12 at 12:16 AM

Seen: 455 times

Last Updated: Mar 08 '12 at 02:04 AM