How to cast a gameobject type to a different type?

Matt eyy 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 5

How i can cast float type app variable to string and show it at runtime on UI?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by Matt eyy 2 years ago

Usually you want some control over how the float values are interpreted as a string, precision, leading zero, +/- signs. And for this you should better use the FloatToString node with the Format string parameter.

Don't bother looking to hard into the standard formatting string options, directly use the custom format instead, yet with the three +/-/0 fields option, I found it much more easy to use than any other options to have absolute control over float to strings.

In short, set the Format parameter string this way, for instance:

+00.00;-00.00; 00.00

The three fields separated by a semi colon indicate how to format your float when: it is positive;it is negative; it is zero.

Then the +/- sign are optional, if you put it they will be displayed. Note the space before the zero formatting option, it will be taken into account so if you use fixed font the zero value will be aligned with the +/- versions.

Then the "0" are place holders and enforce leading zero if more than one zero before the decimal point, and the precision after it.

Hope this helps.

very useful information, but i still don't know how cast any application variable to string


Usually, Objects have there own ToString() method. You then just have to use that Method by fuzzy find the Object Class, then choose the ToString() method. Then just plug the given node to the GetVariable node output.


That is indeed the right approach!