Last active
February 13, 2019 03:09
-
-
Save tsubaki/a7be4ce3240bc8869503706bc711d879 to your computer and use it in GitHub Desktop.
TextMeshProにて、GC無しで数字を表現する(ビルド後のみ・5桁まで)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using TMPro; | |
public class ShowCharacter : MonoBehaviour | |
{ | |
[SerializeField] | |
TextMeshProUGUI label; | |
[Range(0, 99999)] | |
[SerializeField] | |
int count; | |
int[] characters = new int[5]; | |
void Update() | |
{ | |
var value = count; | |
for(int i= characters.Length - 1; i>=0 ; i--) | |
{ | |
characters[i] = (value % 10) + 48; | |
value /= 10; | |
} | |
label.SetCharArray(characters, 0, characters.Length); | |
} | |
} |
Author
tsubaki
commented
Feb 3, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment