How to specify the format in toString units

Skypatcher 4 years ago updated by Jöran Malek 4 years ago 3

Hi, I have trouble setting formats in int.toString and float.toString units.

The Graph Inspector indicates there are more info in Remarks, but I couldn't find any remarks. There is no mention of it in Unit Reference either.  By experiment, it seems I don't need to enclose the format inside the braces "{" "}" for simple formatting. 

I tried a few variations, but still can't format an integer right-justified into a 3-column width, which normally is done using {0,3:D}. Any suggestion?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by Skypatcher 4 years ago

@Lazlo @AliveDevil The string format demonstrated in scriping-api is cool! Thanks for showing the example, It will be useful for me and others later.

For my particular problem, I had decided to use string.Format unit to format an integer right-justified into a 3-column width. I just use {0,3:D}.  It is not ideal because I need to use 2 units (the string.Format and the string literal).  This question can be closed now.


Think I'll add this support to my extensions library aswell.