Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Last active December 20, 2015 08:18
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 AngryAnt/6099157 to your computer and use it in GitHub Desktop.
Save AngryAnt/6099157 to your computer and use it in GitHub Desktop.
Display an integral value in separate textures of digits. Untested.
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