..which does nothing as I have no idea what the 1's and 0's represent. Can anyone shed some light on this?
the numbers before the colon represent the index of the objects after the formatting strin. SO in your example, 0 is displayDays, 1 is displayHours and 2 would be displaySeconds.
This answer is awful. You do not explain what the heck {0:d2} means. It may be "short and simple" when you understand it, but looking at {0:d2} really makes no sense by itself. Telling people it's easy doesn't actually help them understand.
And that gives me 00:00:00:00 with the correct vars assigned to the correctly formatted areas.
Right, the first zero is the order of the variable to show. The 00 means the minimum number of digits to use for displaying that value. Two zeros tell the parser to display the single-digit values (1, 2, 3...) with a leading 0: 01,02,03. Using 000 would lead to 001, 002, 003. Also, if your values are float, you can specify the number of decimal digits to use by adding a dot and the desired number of decimals as zeros: {0:00.000} --> 03.234
You can also use the String.padLeft() and String.PadRight() methods. strBlah.ToString().PadLeft(2, '0'); Plus, if you want to search for info - you can use MSDN since the methods in Mono and in .NET are the same. The implementation might be a bit different, but they are compatible and implement the same specs.
Here's the bit of code I'm using to display floating point seconds as MM:SS.FF ...
string FormatSeconds(float elapsed)
{
int d = (int)(elapsed * 100.0f);
int minutes = d / (60 * 100);
int seconds = (d % (60 * 100)) / 100;
int hundredths = d % 100;
return String.Format("{0:00}:{1:00}.{2:00}", minutes, seconds, hundredths);
}
(EDIT) Recently realized I can simply use System.DateTime, as demonstrated in this javascript fragment:
var date : System.DateTime;
date = new System.DateTime(seconds * System.TimeSpan.TicksPerSecond);
If you want it as a nicely formatted string, use date.ToString(). This can also take a format parameter to control the formatting details, see MSDN docs for more info.
Ive never tried this but I would be tempted to inject the legacy animation in to the OnAnimator callbacks or in LateUpdate (which should be kept minimal).
the numbers before the colon represent the index of the objects after the formatting strin. SO in your example, 0 is displayDays, 1 is displayHours and 2 would be displaySeconds.
– Structed