Answer the question
In order to leave comments, you need to log in
How to make text shortening in Unity via C#?
I know it sounds stupid, but I can't really do what I want. In general, I need that when, for example, 1000 points are scored, they themselves are converted to 1k and so on with other numbers, I think you understand. I did it like this:
int k = 1000;
if (score >= 1000) {
//Тут я минусовал кол-во очков и в конце кол-ва прибавлял k
}
Answer the question
In order to leave comments, you need to log in
You have a variable responsible for the points and there is a line (for example in the Text component) that will have a different value. Something along the lines of:
if (score >= 1000 && score < 1000000)
scoreText.Text = (score / 1000f).ToString() + "k";
else if (score >= 1000000 && score < 1000000000)
scoreText.Text = (score / 1000000f).ToString() + "m";
else scoreText.Text = score.ToString();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question