Logo
UI Elements

Counter

Animate numeric labels with rolling digits

Overview

Counter animates changes to a numeric label. Featuring rolling digits, with controls for stagger, travel distance, and fading.

Preview

Usage

Add Counter to an object and assign its text component. Any text provider works.

Set the initial value and display format.

Call SetValue() for an animated change or SetValueInstant() for immediate updates.


Tips

  • Use Roll Through Digits to roll through intermediate digits.
  • Counter Duration, Minimum Step Duration, and Digit Stagger shape the timing; Roll Distance and Fade Amount control the appearance.
  • Use Unscaled Time lets the animation continue while gameplay is paused.
  • Use Uniform Digit Width stops changing digits from shifting the number. With TextMesh Pro, it requires Rich Text on the text, and Digit Width Scale adjusts the measured digit width. UniText uses the font's tabular figures instead.

Public API

Use Counter in the Evo.UI namespace.

value stores the target number and CurrentValue reports the displayed number during animation. Use SetValue() or SetValueInstant() to update the display.

Properties

NameTypeDescription
CurrentValuefloatRead-only displayed value during animation.
IsAnimatingboolWhether an animation is running.

Fields

NameTypeDescription
valuefloatTarget numeric value.
displayFormatNumberDisplayFormatShared number format.
textFormatstringText template containing 0.
rollThroughDigitsboolRolls through intermediate digits.
counterDurationfloatBase duration of the change.
digitStaggerfloatDelay between digit animations.

Methods

NameParametersDescription
SetValue()float newValueAnimates toward the new value.
SetValue()int newValueAnimates toward the new value.
SetValueInstant()float newValueDisplays the new value immediately.
SetValueInstant()int newValueDisplays the new value immediately.
AddToValue()float amountAdds to the target value and animates.
SubtractFromValue()float amountSubtracts from the target value and animates.

Example

CounterExample.cs
using UnityEngine;
using Evo.UI;

public class CounterExample : MonoBehaviour
{
    [SerializeField] private Counter target;

    private void Start()
    {
        target.SetValueInstant(0);
        target.textFormat = "Score: {0}";
        target.SetValue(1250);
    }
}

On this page