Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created February 3, 2019 17:33
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/f88863d3c8e1b3c0a0c8fb963ab22991 to your computer and use it in GitHub Desktop.
Save tsubaki/f88863d3c8e1b3c0a0c8fb963ab22991 to your computer and use it in GitHub Desktop.
SetCharArrayのChar版
using UnityEngine;
using TMPro;
public class ShowCharacter4 : MonoBehaviour
{
[SerializeField]
TextMeshProUGUI label;
[Range(0, 99999)]
[SerializeField]
int count;
char[] characters = new char[5];
const char zero = '0';
void Update()
{
var value = count;
for (int i = characters.Length - 1; i >= 0; i--)
{
characters[i] = (char)((value % 10) + zero);
value /= 10;
}
label.SetCharArray(characters, 0, characters.Length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment