using System.Collections.Generic; using TMPro; using UnityEngine; using IFont = UnityEngine.Font; namespace Cryville.Common.Unity.UI { [RequireComponent(typeof(TextMeshProUGUI))] public class TMPAutoFont : MonoBehaviour { public static readonly List Fonts = new List { "Arial", }; static TMP_FontAsset _font; TextMeshProUGUI _text; void Awake() { _text = GetComponent(); if (_font == null) { var _ifont = new IFont("C:/Windows/Fonts/arial.ttf"); _font = TMP_FontAsset.CreateFontAsset(_ifont); } _text.font = _font; } } }