unity 字体碎了
下面截图来自unity文档
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UIFontDirty : MonoBehaviour
{
bool isDirty = false;
Font dirtyFont = null;
private void OnEnable()
{
Font.textureRebuilt += FontChanged;
}
private void OnDisable()
{
Font.textureRebuilt -= FontChanged;
}
void LateUpdate()
{
if (isDirty)
{
isDirty = false;
var texts = transform.GetComponentsInChildren<Text>();
foreach (Text text in texts)
{
if (text.font == dirtyFont)
{
text.FontTextureChanged();
}
}
dirtyFont = null;
}
}
void FontChanged(Font font)
{
isDirty = true;
dirtyFont = font;
}
}
雨松MOMO 2016年10月26日 于 雨松MOMO程序研究院 发表