ToString()

How do I control the results of .ToString() method?

I see in the Race Demo the following line:

guiSpeed.text = kmPerH.ToString(“f1”) + “\t km/h”;

What does '“f1” do? I assumed it trucated the float, but if I try the same thing with rigidbody.velocity.magnitude, I get an error message.

Any info in the docs? I can’t find any.

Mitch

ToString() is a C# function… you can find great reference for all C# stuff online at places like msdn.microsoft.com or google it…

Basic formatting lets you do things like… To.String(“0.00”) to make a float format with 2 decimal places.

You can also do things like… To.String().PadLeft(" "[0],6) to pad a string on the left hand side with a " " up to 6 characters…

Its quiet a cool and extensive function. As I said… penty of online reference for it…

the F1 is fixed point… Standard numeric format strings - .NET | Microsoft Learn

Ah - that’s great. Thanks for the link.