Optimize GC for status info.

This commit is contained in:
2023-01-31 22:56:06 +08:00
parent cbc874dd72
commit 969fdc8069
6 changed files with 75 additions and 36 deletions

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57404eb6519ecae44b051485280e879f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: