How to load font into variable
I have .ttf font called Kubasta that put into Assets > font folder. I call it like this, but get an error.
void OnGUI() {
GUIStyle myStyle = new GUIStyle();
myStyle.font = kubasta;
GUI.Label(new Rect(10,10, 100, 30), "Hello World!", myStyle);
if (!kubasta) {
Debug.LogError("No font found, assign one in the inspector.");
return;
}
}
I've tried calling it by it's file name Kubasta.ttf, Kubasta, and kubasta but i get the error, 'Debug.LogError("No font found, assign one in the inspector.");' in it's current context.
What's going on?
Comment
you probably need to add a GUIText
component and reference the font from that. take a look here