Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active February 2, 2019 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/acd0cbc7a56ce74716fe052f526bec3d to your computer and use it in GitHub Desktop.
Save tsubaki/acd0cbc7a56ce74716fe052f526bec3d to your computer and use it in GitHub Desktop.
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