ToString requires '1' arguments

I typed this line of code from a tutorial exactly yet I got an error that said “ToString requires ‘1’ arguments.”

(timeDisplay is a Text variable) I have version 5.3.5 if that helps.

Need more info on what youre trying to do.

That “f0” operator is for numeric values. If timeDisplay is a string, you may have to use concatenation and format it yourself.

The ToString method you’re trying to use is not what you think it is. If “timeDisplay” is of type Text(from UnityEngine.UI namespace) then the ToString method being invoked here is on the UnityEngine base Object type, it’s an override method that takes zero parameters and outputs whatever Unity whats it to. That said, if you want to format the text, from the text property of a Text type do something like:

timeDisplay.text = timeDisplay.text.ToString("f0");

This will take the value from timeDisplay.text and format it if it can, the ToString being invoked in this case on a String type will be from the System namespace in .net rather then the over ride you’re currently.

With all that said, should the time information be a internal variable of string type that you formatting into the Text type text property. Seems like you want to format the text set on the text property, then once it’s formatted then what happens? I would again add a temp variable or private variable for your time calculations then format for the one screen UI, keep them separate.