Skip to content

Instantly share code, notes, and snippets.

@tsubaki tsubaki/UpdateText .cs
Last active Feb 2, 2019

Embed
What would you like to do?
using UnityEngine;
// for Text Mesh Pro 1.4 previewで
// フォントが一杯になると使えなくなる問題の場当たり的対処法
// (多分将来的に不要になる)
public class UpdateText : MonoBehaviour
{
TMPro.TextMeshProUGUI label;
private void Awake()
{
label = GetComponent<TMPro.TextMeshProUGUI>();
}
public void SetText(string str)
{
if (!label.font.TryAddCharacters(str))
{
label.font.ClearFontAssetData();
label.font.TryAddCharacters(str);
}
label.text = str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.