Esempio n. 1
0
    private void OnValueChange(object value)
    {
        if (valueText == null)
        {
            return;
        }
        if (value == null)
        {
            return;
        }

        ulong changedValue = PersitenData.ToULong(value);

        if (changedValue < 2)
        {
            valueText.text = CurrentValue.ToString();
        }
        else
        {
            if (coroutine != null)
            {
                StopCoroutine(coroutine);
                coroutine = null;
            }
            coroutine = StartCoroutine(IETextCounter(valueText, CurrentValue - changedValue, CurrentValue));
        }
    }
Esempio n. 2
0
    IEnumerator IETextCounter(TextMeshProUGUI text, ulong current, ulong target)
    {
        if (text == null)
        {
            yield break;
        }

        ulong start = current;

        for (float timer = 0; timer < valueCounterDuration; timer += Time.deltaTime)
        {
            float progress = timer / valueCounterDuration;
            current   = PersitenData.ToULong(Mathf.Lerp(start, target, progress));
            text.text = current.ToString();
            yield return(null);
        }
        text.text = target.ToString();
    }