Logo
UI Elements

Quantity Selector

Choose an integer with buttons or direct input

Overview

Quantity Selector combines increase/decrease buttons with a numeric input. It keeps the value within an integer range and can animate changes.

Preview

Usage

Create a Quantity Selector prefab.

Set Min Quantity and Max Quantity.

Bind On Value Changed to your quantity setting.


Public API

Use QuantitySelector in the Evo.UI namespace.

Properties

NameTypeDescription
CurrentQuantityintCurrent integer value.

Fields

NameTypeDescription
minQuantityintMinimum allowed quantity.
maxQuantityintMaximum allowed quantity.

Methods

NameParametersDescription
Increase()NoneIncreases by one within the range.
Decrease()NoneDecreases by one within the range.
SetQuantity()int value, bool animate = trueSets a quantity with optional animation.

Events

NameTypeDescription
onValueChangedUnityEvent<int>Invoked with the quantity.

Example

QuantitySelectorExample.cs
using UnityEngine;
using Evo.UI;

public class QuantitySelectorExample : MonoBehaviour
{
    [SerializeField] private QuantitySelector target;

    private void Start()
    {
        target.minQuantity = 1;
        target.maxQuantity = 10;
        target.SetQuantity(3, animate: false);
        target.onValueChanged.AddListener(quantity =>
            Debug.Log($"Quantity: {quantity}"));
    }

    public void ResetQuantity()
    {
        target.SetQuantity(1); // Keeps the input and buttons synchronized.
    }
}

On this page