Unity中千分计数

 主要还是弄清楚Mathf.Pow的用法就好了

using UnityEngine;

public class UtilityCoin
{
    static float a;
    static string b;
    static string[] unit = new string[] {" ","k","m","b","ab","ac","ad","ae","af","ag","ah","ai","aj","ak"};
    public static string setCoinShow(string Count)
    {
        a = float.Parse(Count);
        b = "0";
        for (int i = 0; i < unit.Length; i++)
        {
            if (a < Mathf.Pow(10, (i + 1) * 3))
            {
                b = (a / Mathf.Pow(10, (i) * 3)).ToString("#0.0") + unit[i];
                return b;
            }
        }
        return b;
    }

    public static string setCoinShow(float Count)
    {
        a = Count;
        b = "0";
        for (int i = 0; i < unit.Length; i++)
        {
            if(a

 

你可能感兴趣的:(Unity学习)