コード例 #1
0
    public static string GetCountryCode()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass  jc      = new AndroidJavaClass("java.util.Locale");
        AndroidJavaObject jo      = jc.CallStatic <AndroidJavaObject>("getDefault");
        string            country = jo.Call <string>("getCountry");
#elif UNITY_IOS && !UNITY_EDITOR
        string country = Locale.GetCountryCode();
#else
        string country = "CN";
        if (!string.IsNullOrEmpty(CultureInfo.CurrentCulture.Name))
        {
            RegionInfo re = new RegionInfo(CultureInfo.CurrentCulture.Name);
            country = re.TwoLetterISORegionName;
        }
#endif
        return(country);
    }
コード例 #2
0
    public void LoadCurrencySymbol()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass  jc      = new AndroidJavaClass("java.util.Locale");
        AndroidJavaObject jo      = jc.CallStatic <AndroidJavaObject>("getDefault");
        string            country = jo.Call <string>("getCountry");
#elif UNITY_IOS && !UNITY_EDITOR
        string country = Locale.GetCountryCode();
#else
        string country = "CN";
        if (!string.IsNullOrEmpty(CultureInfo.CurrentCulture.Name))
        {
            RegionInfo re = new RegionInfo(CultureInfo.CurrentCulture.Name);
            country = re.TwoLetterISORegionName;
        }
#endif

        if (country == "CN")
        {
            currencySymbol = ECurrencySymbol.CNY;
        }
        else if (country == "HK")
        {
            currencySymbol = ECurrencySymbol.HKD;
        }
        else if (country == "TW")
        {
            currencySymbol = ECurrencySymbol.TWD;
        }
        else if (country == "MO")
        {
            currencySymbol = ECurrencySymbol.MOP;
        }
        else if (country == "KR")
        {
            currencySymbol = ECurrencySymbol.KRW;
        }
        else
        {
            currencySymbol = ECurrencySymbol.USD;
        }
    }