Home > Enterprise >  how to change text displayed by VerticalLayoutGroup?
how to change text displayed by VerticalLayoutGroup?

Time:03-30

I have a text that is located at the upper right of the screen using VerticalLayoutGroup.

  static TextMeshProUGUI CreateText(Transform parent)
    {
        var go = new GameObject();
        go.transform.parent = parent;
        var text = go.AddComponent<TextMeshProUGUI>();
        text.fontSize = 15;      
        return text;
    }

I wonder if it is possible to change the font of this text? I tried this :

Font ArialFont = (Font)Resources.GetBuiltinResource(typeof(Font), "LemonTea.ttf");

but didn't work. please help.

CodePudding user response:

There you go :)

This is how to change a font of a Textmeshpro

public TextMeshProUGUI textToChange;
public TMP_FontAsset FontAssetA;

// Start is called before the first frame update
void Start()
{
    // Assign the new font asset.
    textToChange.font = FontAssetA;

}
  • Related