Erwin
Erwin

Reputation: 15

Unity - "Unrecognized escape sequence"

I have a really annoying error, I made a stopwatch in unity and this error keep showing up... Here's the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StopWatch : MonoBehaviour
{
    float currentTime;   
    public Text currentTimeText; 

    void Start()
    {
        currentTime = 0;
    }

    void Update()
    {
        currentTime = currentTime + Time.deltaTime;
        TimeSpan time = TimeSpan.FromSeconds(currentTime);
        currentTimeText.text = time.ToString("@mm\:ss\:fff");
    }
}

I don't know what to do, Im new to C#. Thank you! :)

Upvotes: 0

Views: 203

Answers (1)

Szpur
Szpur

Reputation: 119

change:

currentTimeText.text = time.ToString("@mm\:ss\:fff");

to:

currentTimeText.text = time.ToString(@"mm\:ss\:fff");

or:

currentTimeText.text = time.ToString("mm\\:ss\\:fff");

Upvotes: 1

Related Questions