using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [ExecuteAlways] public class FontSwitch : MonoBehaviour { [SerializeField] FontType m_FontType = FontType.Preferred; public FontType fontType { get { return m_FontType; } set { m_FontType = value; } } Text m_Text; public Text text { get { return m_Text ?? (m_Text = this.GetComponent()); } } [ExecuteAlways] private void Awake() { switch (m_FontType) { case FontType.Preferred: text.font = FontUtility.preferred; break; case FontType.Secondary: text.font = FontUtility.secondary; break; } } public enum FontType { None, Preferred, Secondary } }