- Home /
money counter with thousand separators?
Hi there. I have this script:
var money = 0.0;
var moneyFormatted = String.Format("{0:#,###0}", money);
GetComponent(TextMesh).text = "竄ャ" + moneyFormatted;
var increase = 336;
function Start () {
InvokeRepeating("AddToMoney", 1.0, 1.0);
}
function AddToMoney () {
money += increase;
//guiText.text = "Money wasted: €" + money;
GetComponent(TextMesh).text = "€" + money;
}
Probably very easy, I'm not much of a coder. BUT, this money number will get real high in a few hours, so it would be really nice if I could have something within the script that makes sure that 45234531 looks like 45.234.531. Can anyone of you please help me out?
thanks in advance
grts dmvd
Answer by Happy-Zomby · Sep 08, 2020 at 04:26 PM
If someone stumble over this old post and like me are using the .ToString() method. You can use this - money.ToString("n0"); See this answer https://answers.unity.com/questions/12981/seperate-large-numbers-with-comma.html
Your answer
Follow this Question
Related Questions
Resouce script help 3 Answers
GuiText Score On Mouse Click 1 Answer
Roguelike Elements... 1 Answer
Counter problem 1 Answer
Counting colors and keeping it in memory (javascript) 0 Answers