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.
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
| Name | Type | Description |
|---|---|---|
CurrentQuantity | int | Current integer value. |
Fields
| Name | Type | Description |
|---|---|---|
minQuantity | int | Minimum allowed quantity. |
maxQuantity | int | Maximum allowed quantity. |
Methods
| Name | Parameters | Description |
|---|---|---|
Increase() | None | Increases by one within the range. |
Decrease() | None | Decreases by one within the range. |
SetQuantity() | int value, bool animate = true | Sets a quantity with optional animation. |
Events
| Name | Type | Description |
|---|---|---|
onValueChanged | UnityEvent<int> | Invoked with the quantity. |
Example
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.
}
}