H Alyafai
H Alyafai

Reputation: 31

How to change font in realtime in Unity?

I tried to change the font by the C# script in the real time. it changed in the inspector but the text mesh looks like blended.
When I pause and change to another font and return to the desired one it looks fine.

So how do I fix this issue ?
is it a bug ?

EDIT
Here is my code:

public TextMesh text;

void Awake()
{
     en_font = Resources.Load<Font>(“font Name”);
     text.font = en_font;
}

Upvotes: 0

Views: 10713

Answers (1)

dev-masih
dev-masih

Reputation: 4746

Try This Code :

Font ArialFont = (Font)Resources.GetBuiltinResource (typeof(Font), "Arial.ttf");
textMesh.font = ArialFont;
textMesh.renderer.sharedMaterial = ArialFont.material;

Upvotes: 7

Related Questions