- Home /
Other-Question is not specific enough: Please try yourself, this is a HUGE ask and not appropriate for UA. This is a design question and require significant back and forth, please consider use the forums.
Digital Clock Needed For New UI Text
I have been looking for a way to make a simple digital clock that uses the new UI text. It just needs to display the current time in Hours, minutes and seconds and have an Am or PM display as well something like:
05:43:21 AM
Bonus if it can be made to display the date as well like: Aug. 09 2015
Answer by PorkMuncher · Jan 29, 2015 at 07:27 PM
System.DateTime.Now
I have this nice little script that I tweaked to suit my needs more but I want to see if I can add in an A$$anonymous$$ or P$$anonymous$$ display too?
#pragma strict
var ClockText : GUIText; // Hierarchy DRAG E DROP over var GUI Text in Inspector
var ClockDateText : GUIText; // Hierarchy DRAG E DROP over var GUI Text in Inspector
var ClockSecondsText : GUIText; // Hierarchy DRAG E DROP over var GUI Text in Inspector
private var dt = Date();
function Update () {
var day = dt.Now.Day;
var month = dt.Now.$$anonymous$$onth;
var year = dt.Now.Year;
var hours = dt.Now.Hour;
var $$anonymous$$utes = dt.Now.$$anonymous$$inute;
var seconds = dt.Now.Second;
ClockText.text = hours + ":" + $$anonymous$$utes;
ClockDateText.text = day + " " + month + " " + year + " ";
ClockSecondsText.text = seconds + " ";
}
Follow this Question
Related Questions
Why will this timer not count down? 1 Answer
Why does fixed Timestep affect deltatime in Update? 2 Answers
Time.deltatime is returning 0? 1 Answer