I use Unity to create an "incremental game", also known as an "Idle Game", and I'm trying to format large numbers. For example, when gold says 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 ("#,#");
I searched for other examples while searching the Internet where gold.ToString ("#,#"); came from gold.ToString ("#,#"); However, none of them worked.
source share