private void ResetNumberTo(iTweenData data, GameObject target) { if (!data.Values.ContainsKey("from") || !data.Values.ContainsKey("to")) { Debug.LogWarning(target + ":" + data.internalName + " not have from or to key ,can't reset"); return; } var from = (float)data.Values["from"]; var label = target.GetComponent<UILabel>(); if (!data.Values.ContainsKey("format")) { data.Values["format"] = iTweenData.NumberFormat.NOPoint; } iTweenData.NumberFormat format = (iTweenData.NumberFormat)data.Values["format"]; label.text = GetNumberFormat(from, format); }
public static string GetNumberFormat(float value, iTweenData.NumberFormat format) { switch (format) { case iTweenData.NumberFormat.OnePoint: return value.ToString("#0.0"); break; case iTweenData.NumberFormat.TwoPoint: return value.ToString("#0.00"); break; case iTweenData.NumberFormat.ThreePoint: return value.ToString("#0.000"); break; case iTweenData.NumberFormat.NormalTime: var val = Mathf.RoundToInt(value); return DateTimeUtil.SecondToStringNoDay(val, DateTimeUtil.TimeLanguage.Symbol, DateTimeUtil.TimePrecision.Mutant); ; break; default: return value.ToString("#0"); break; } }