Scripting Support (C#)
advanced scriptingDigits FX · Scripting Support (C#)
Digits base class. Use Digits3D for 3D world-space or DigitsUI for UI Canvas. Access via GetComponent<Digits3D>() or GetComponent<DigitsUI>().
Getting Started
Add using DigitsFX; at the top of your script. Use Digits3D for 3D world-space displays and DigitsUI for UI Canvas displays. Both inherit from the Digits base class.
using DigitsFX;
// UI display
DigitsUI digits = GetComponent<DigitsUI>();
digits.value = 1234.56;
digits.AnimateTo(9999, duration: 2f);
profile.tremble, profile.glow, profile.shadow, etc.), call UpdateMaterialProperties() afterwards to apply the changes:
var p = digits.profile;
p.tremble = true;
p.glow = true;
digits.UpdateMaterialProperties();
This is required because these effects are shader-based. Properties like value or animationDuration do not require this call.
Digits (Base Class)
Properties
double value { get; set; }
double animationTargetValue
ProgressBarSource progressBarSourceSource for progress bar value: DigitsValue or UserDefined. Default: DigitsValue.
double progressBarMinValueMinimum value for progress bar range mapping.
double progressBarMaxValueMaximum value for progress bar range mapping. Default: 100.
float progressBarProgressDirect progress bar value (0–1) when progressBarSource is UserDefined. Default: 0.5.
Target value for the current animation.
AutoplayType autoplayAutoplay mode triggered on enable: defines how the animation starts automatically.
CounterDirection counterDirectionDirection for counter animations: Up or Down. Default: Up.
AnimationDurationScope animationDurationScopeHow animation duration is applied: PerStep (duration per digit change) or EntireAnimation (total duration). Default: PerStep.
Current displayed numeric value. Setting this directly updates the display without animation.
bool isAnimating { get; }Whether an animation is currently playing.
DigitsProfile profile { get; set; }Per-instance profile. Automatically clones the shared profile for safe per-object customization.
DigitsProfile sharedProfile { get; set; }Direct reference to the shared profile asset. Changes affect all objects sharing this profile.
bool showValueControls visibility of the digit display.
bool showProgressBarEnable the progress bar display.
float progressBarValue { get; set; }Get or set the progress bar value directly (0–1).
float globalAlphaGlobal alpha/opacity of the entire display (0–1).
float animationDurationDefault animation duration in seconds.
static bool useUnscaledTimeToggle between scaled and unscaled time for all Digits instances.
Events
DigitsEvent onAnimationStart(Digits digits)Triggers when an animation starts. Callback receives the Digits instance.
DigitsEvent onAnimationStep(Digits digits)Triggers at each animation step (per integer change).
DigitsEvent onAnimationStop(Digits digits)Triggers when the animation completes.
Methods
void AnimateTo(double newNumber, float duration = -1, AnimationDurationScope durationScope = PerStep)Animate the digits to newNumber using the profile's transition effect. Duration semantics:
duration < 0(default-1): use the profile'sanimationDuration(live-tracked, so editing it at runtime affects the animation in progress).duration == 0: snap immediately tonewNumberwith no animation.duration > 0: animate over the given number of seconds.
void TriggerVanishOnStep(float? duration = null)Trigger a vanish effect on each animation step. Pass null to use the profile default duration.
void UpdateMaterialProperties()Updates all material properties. Call after changing visual settings via script.
static float GetTime()Returns the current time value used by all Digits instances, respecting the useUnscaledTime setting.
Animate the digits to a new value with optional custom duration.
- newNumber
- Target value to animate to.
- duration
- Animation duration (-1 = use default).
- durationScope
PerStep(duration per digit change) orEntireAnimation(total duration).
void Add(double amount, float duration = -1, AnimationDurationScope durationScope = PerStep)Add a value to the current display and animate the change.
void Subtract(double amount, float duration = -1, AnimationDurationScope durationScope = PerStep)Subtract a value from the current display and animate the change.
void StartCounter(CounterDirection direction = Up, float duration = -1, AnimationDurationScope durationScope = PerStep)Start a continuous counter animation that counts up or down.
void Stop(bool withStopNotification = true)Stop the current animation. Set withStopNotification to false to suppress the onAnimationStop event.
void Play()Start the autoplay animation based on the current autoplay settings.
void TriggerPulse(bool affectsProgressBar = false, float? pulseDuration = null, ...)Trigger a pulse/scale effect on the display. All parameters are optional — pass null to use profile defaults.
void TriggerShake(float? intensity = null, float? duration = null)Trigger a shake effect on the digits.
void TriggerMoveAndScale(float? duration = null, EasingType? easing = null, Vector3? moveAmount = null, ...)Trigger a move and scale effect. All parameters are optional.
void Refresh(bool forceRebuild = false)Refresh the display and update material properties. Set forceRebuild to true to force font data extraction.