I am using Unity to make an "Incremental Game" also known as an "Idle Game" and I am trying to format large numbers. For example, when gold
gets to say 1000 or more, it will display as Gold: 1k
instead of Gold: 1000
.
using UnityEngine;
using System.Collections;
public class Click : MonoBehaviour {
public UnityEngine.UI.Text GoldDisplay;
public UnityEngine.UI.Text GPC;
public double gold = 0.0;
public int gpc = 1;
void Update(){
GoldDisplay.text = "Gold: " + gold.ToString ("#,#");
//Following is attempt at changing 10,000,000 to 10.0M
if (gold >= 10000000) {
GoldDisplay.text = "Gold: " + gold.ToString ("#,#M");
}
GPC.text = "GPC: " + gpc;
}
public void Clicked(){
gold += gpc;
}
}
I have tried other examples while searching online, which is where gold.ToString ("#,#");
came from, however none of them worked.