Last active
December 20, 2015 08:18
-
-
Save AngryAnt/6099157 to your computer and use it in GitHub Desktop.
Display an integral value in separate textures of digits. Untested.
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
Texture2D[] m_Numbers, m_Digits; | |
void SetValue (int value) | |
{ | |
if (value >= Mathf.Pow (10, m_Digits.Length)) | |
{ | |
Debug.LogError ("Value overflow: Unable to display value: " + value); | |
} | |
for (int i = m_Digits.Length - 1; i >= 0; --i) | |
{ | |
int step = Mathf.Min (Mathf.Pow (10, i), 1); | |
m_Digits[i] = m_Numbers[value / step]; | |
value %= step; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment