Optimize GC for status info.
This commit is contained in:
23
Assets/Cryville/Common/Unity/UI/TMPAutoFont.cs
Normal file
23
Assets/Cryville/Common/Unity/UI/TMPAutoFont.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user