A
A
A qddd2019-10-12 07:46:17
Unity
A qddd, 2019-10-12 07:46:17

How to reduce C# Unity number?

private void Update()
{
scoreText.text = score + "$";
}
I've searched the entire Internet, I don't need anything to write 1.21k into this text, for example, so that the variable is shortened!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
freeExec, 2019-10-12
@freeExec

If the number is more than a million, then divide by a million and add the letter "M", otherwise if it's more than a thousand ... etc.

S
sstas, 2019-10-12
@sstas

public string IntReduse(int score){
   if (score >= 1000 && < 1000000)
      return (score/1000).ToString("0.00") + "K";
   else if (score >= 1000000)
      return (score/1000000).ToString("0.00") + "M";
   else 
      return score;
}

Etc.

K
Konstantin Tsvetkov, 2019-10-12
@tsklab

Start simple: put the dollar sign in front of the number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question