timer problem

i need to find a simple way to write 0:00:00 into a gui text format with each 0 behind : being a different varible. so basically hours minutes and seconds.

i can do all this and tell it every 60 seconds add one to minutes and so on, but the one thing i cant seem to do is write 0:00:00. i can write it as numbers beside one another but i need the : between them which i just cant do

i did try something like

GUIText.text = “” +Hour+Minutes+Seconds;

but i cant seem to fit : anywhere any ideas

While it works this way too, it’s not very clean, flexible or even readable.

usually you will use string format functions for this.

For example, if your minutes are in 1-digit area, the result of 5 hours, 3 minutes and 5 seconds would be: “5:3.5” which is not something you want.

Instead use string formating.

guiText.text = string.Format("{0:D2}:{1:D2}.{2:D2}", Hour, Minutes, Seconds);

D tells it that it’s a digit and 2 the number how often.

So guiText.text = string.Format("{0:D5}", 5); will output 00005 (since 5 is 1-digit, the remaining will be filled with zeros)

dont matter i got it i was missing out the extra + between each :

guiText.text = Hour+“:”+Minutes+“:”+Seconds;