Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

GUISkin.font

var font: Font;
Font font;
font as Font

Description

The default font to use for all styles.

	// Modifies the font only of the current GUISkin.

var f : Font;

function OnGUI() { if(!f) { Debug.LogError("No font found, assign one in the inspector."); return; } GUI.skin.font = f; GUILayout.Label("This is a label with the font"); GUILayout.Button("And this is a button"); }

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Font f;
    void OnGUI() {
        if (!f) {
            Debug.LogError("No font found, assign one in the inspector.");
            return;
        }
        GUI.skin.font = f;
        GUILayout.Label("This is a label with the font");
        GUILayout.Button("And this is a button");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public f as Font

	def OnGUI() as void:
		if not f:
			Debug.LogError('No font found, assign one in the inspector.')
			return
		GUI.skin.font = f
		GUILayout.Label('This is a label with the font')
		GUILayout.Button('And this is a button')