Quantcast
Channel: Answers for "Count down timer C#"
Viewing all articles
Browse latest Browse all 22

Answer by Loomabox

$
0
0
Please, need help. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CountdownTimer : MonoBehaviour { float timeLeft = 300.0f; public Text Timer; // Use this for initialization void Start () { } // Update is called once per frame void Update () { timeLeft -= Time.deltaTime; int minutes = Mathf.FloorToInt(timeLeft / 60f); int seconds = Mathf.FloorToInt(timeLeft - minutes * 60); Timer.text = string.Format("{0.D2}:{1.D2}", minutes, seconds); } } Getting this error in editor: FormatException: Input string was not in a correct format. System.String.ParseFormatSpecifier (System.String str, System.Int32& ptr, System.Int32& n, System.Int32& width, System.Boolean& left_align, System.String& format) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:2535) System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1923) System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1873) System.String.Format (System.String format, System.Object arg0, System.Object arg1) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1858) CountdownTimer.Update () (at Assets/Scripts/CountdownTimer.cs:23)

Viewing all articles
Browse latest Browse all 22

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>