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)
↧