- Home /
No overload for method 'ToString' takes '1' arguments: YES IT DOES!
This tiny code just updates my gui with the correct ingame time. It compiles in Visual C# but Unity says that ToString doesn't have anything that takes only 1 argument when obviously it does! What's the deal here?
private void UpdateTime()
{
time = TimeControl.CurrentTime.ToString("hh:mm tt");
}
Ehm, I think the problem starts with that TimeControl isn't in the scripting reference. What library are you using?
TimeControl is a class of my own, attached to my main camera.
You might have to show us the TimeControl script. Its hard to tell without it.
Have you tried passing different parameters? I'm honestly not familiar with them but I use the "f[0-9]" so it definitly can take one(1) argument.
Answer by Bampf · Apr 24, 2011 at 08:00 PM
The overload of TimeSpan.ToString that takes a format string as an argument was not added until .NET 4.0. Unity's current version of Mono is effectively .NET 3.5.
Can you share with other people that stumble across this thread?
Since wildboy didn't bother to post his solution here, check out this one: http://answers.unity3d.com/questions/259482/format-string-$$anonymous$$utesseconds.html
Answer by Eric5h5 · Apr 24, 2011 at 07:36 PM
Have you overridden ToString in your TimeControl class? "hh:mm tt" isn't any kind of standard string format.
Okay maybe I'm just doing the formatting the wrong way...
"CurrentTime = new TimeSpan(Hour, $$anonymous$$inute, 0);" Is all that it really does. I want it to show time like "03:25 A$$anonymous$$", I don't want seconds on there, so I tried that format...How can I do it right?
Your answer
Follow this Question
Related Questions
GameObejct.Find using string variable for name 1 Answer
Error adding Vector3 to Object list 1 Answer
to string. 4 Answers
X.Text just uses random values 1 Answer