Logo
UI Elements

Progress Button

An interactive button with hold-to-complete progress tracking

Overview

Progress Button extends Interactive and provides a hold-to-complete button experience with visual progress feedback. It manages multiple visual states (Normal, InProgress, Complete) with smooth transitions, animated progress fills, and comprehensive event hooks for tracking user interaction throughout the hold duration.

Preview

Customization

Progress Behavior

Configure how long users must hold the button and how quickly it resets. The progress and reset curves allow you to create custom acceleration patterns for a more engaging feel.

Completion Mode

Choose whether the button stays in the complete state or automatically resets after completion. This is useful for confirmations that need to persist versus actions that should reset immediately.

Visual States

The component uses three separate CanvasGroups (Normal, InProgress, Complete) that can each contain different visual elements. These states transition smoothly with configurable scale or slide animations.

Progress Fill

Customize the progress indicator's fill method, origin, and direction. Supports horizontal, vertical, and radial fill patterns to match your UI design.

Interactive Features

As a child of Interactive, Progress Button supports:

  • Interaction states
  • Ripple and trail effects
  • Audio styling
  • Highlight, pressed, and selected transitions

For more information, see the Interactive page.


Properties

Progress Settings

NameTypeDescription
holdDurationfloatTime required to complete the progress
resetDurationfloatTime taken to reset progress back to zero
progressCurveAnimationCurveCurve applied to progress fill animation
resetCurveAnimationCurveCurve applied to reset animation

Completion Settings

NameTypeDescription
stayOnCompleteboolIf true, button remains in complete state without auto-reset
completeStateDurationfloatDuration to display complete state before resetting

Progress Indicator

NameTypeDescription
progressFillImageImage component used to display fill progress
fillMethodImage.FillMethodFill method for the progress indicator
fillOriginFillOriginStarting point for the fill animation
clockwiseboolDirection of radial fill

State Animation

NameTypeDescription
progressTransitionDurationfloatTime for transitioning between states
animationTypeAnimationTypeType of transition (None, Scale, Slide)
animationCurveAnimationCurveCurve for state transition easing
scaleFromfloatStarting scale value for scale animation
slideOffsetVector2Offset distance for slide animation

Canvas Group States

NameTypeDescription
normalStateCGCanvasGroupVisual state when button is idle
inProgressStateCGCanvasGroupVisual state during hold progress
completeStateCGCanvasGroupVisual state when progress is complete

Events

NameTypeDescription
onProgressStartUnityEventFired when user begins holding
onProgressUpdateUnityEvent<float>Fired continuously with progress value (0-1)
onCompleteUnityEventFired when hold duration is reached
onCancelUnityEventFired when hold is interrupted

Public Methods

NameParametersDescription
StartProgress()NoneBegins the progress sequence
CancelProgress()NoneInterrupts and resets the progress
CompleteProgress()NoneImmediately completes the progress
ResetProgress(instant)boolResets progress with optional instant transition
SetProgress(progress)floatManually sets progress value (0-1)

Code Example

ProgressButtonExample.cs
using UnityEngine;
using Evo.UI;

public class ProgressButtonExample : MonoBehaviour
{
    public ProgressButton deleteButton;

    void Start()
    {
        // Configure hold duration
        deleteButton.holdDuration = 2f;
        deleteButton.resetDuration = 0.5f;

        // Configure completion behavior
        deleteButton.stayOnComplete = false;
        deleteButton.completeStateDuration = 1f;

        // Configure animation
        deleteButton.animationType = ProgressButton.AnimationType.Scale;
        deleteButton.progressTransitionDuration = 0.2f;

        // Add event listeners
        deleteButton.onProgressStart.AddListener(() =>
        {
            Debug.Log("User started holding button");
        });

        deleteButton.onProgressUpdate.AddListener(progress =>
        {
            Debug.Log($"Progress: {progress * 100}%");
        });

        deleteButton.onComplete.AddListener(() =>
        {
            Debug.Log("Action confirmed!");
            PerformDeletion();
        });

        deleteButton.onCancel.AddListener(() =>
        {
            Debug.Log("Action cancelled");
        });

        // Programmatic control
        // deleteButton.StartProgress();
        // deleteButton.CancelProgress();
        // deleteButton.SetProgress(0.5f);
    }

    void PerformDeletion()
    {
        // Your deletion logic here
    }
}

On this page