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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Unity/UI/TMPAutoFont.cs.meta
Normal file
11
Assets/Cryville/Common/Unity/UI/TMPAutoFont.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57404eb6519ecae44b051485280e879f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user