Where T, U and V can be integers or floats.
Formatted string containing a pattern and a value representing the text to be displayed.
The string formatting and value declarations is as follows: "The number is:{0}.", value
The {0} refers to where the value will be inserted into the string. Value refers to the integer or float value.
Using {0:2} implies the float will be rounded to two decimal places.
Note: You may wish to use this function instead of TextMeshPro.text if you need to concatenate a string with values and trying to avoid unnecessary garbage collection.
using UnityEngine; using System.Collections; using TMPro; public class ExampleClass : MonoBehaviour { void Example() { TextMeshPro textmeshPro = GetComponent<TextMeshPro>(); textmeshPro.SetText("The first number is {0} and the 2nd is {1:2} and the 3rd is {3:0}.", 4, 6.345f, 3.5f); // The text displayed will be: // The first number is 4 and the 2nd is 6.35 and the 3rd is 4. } }