24 lines
593 B
C#
24 lines
593 B
C#
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<string> Fonts = new List<string> {
|
|
"Arial",
|
|
};
|
|
static TMP_FontAsset _font;
|
|
TextMeshProUGUI _text;
|
|
void Awake() {
|
|
_text = GetComponent<TextMeshProUGUI>();
|
|
if (_font == null) {
|
|
var _ifont = new IFont("C:/Windows/Fonts/arial.ttf");
|
|
_font = TMP_FontAsset.CreateFontAsset(_ifont);
|
|
}
|
|
_text.font = _font;
|
|
}
|
|
}
|
|
}
|