How to Format a Time String with C# in Unity 3D
(This is only here for personal reference, since this is rather basic programming …)
/// <summary> /// Formats the input string (in seconds) as a human readable /// string in the form of MM:SS. /// </summary> /// <returns> /// A <see cref="System.String"/> of the current playing time. /// </returns> private string formatedTimeString (string input) { int seconds; int minutes; minutes = Mathf.FloorToInt(input / 60); seconds = Mathf.FloorToInt(input - minutes * 60); string r = (minutes < 10) ? "0" + minutes.ToString() : minutes.ToString(); r += ":"; r += (seconds < 10) ? "0" + seconds.ToString() : seconds.ToString(); return r; }


Post new comment