UI Elements
Quantity Selector An interactive numeric input with animated transitions
Quantity Selector provides an intuitive way to adjust numeric values with increment and decrement buttons. It features smooth slide animations when values change, automatic button state management based on min/max bounds, and supports both button clicks and direct text input for maximum flexibility.
Name Type Description startQuantityintInitial value when component starts minQuantityintMinimum allowed value maxQuantityintMaximum allowed value
Name Type Description slideOffsetfloatDistance text slides during transitions animationDurationfloatTotal time for slide animation animationCurveAnimationCurveCurve for easing transitions
Name Type Description inputFieldTMP_InputFieldText input for displaying and editing quantity increaseButtonButtonButton for incrementing value decreaseButtonButtonButton for decrementing value
Name Type Description onValueChangedUnityEvent<int>Fired when quantity changes
Name Parameters Description Increase()None Increments value by 1 with animation Decrease()None Decrements value by 1 with animation SetQuantity(value, animate)int, boolSets quantity with optional animation SetQuantity(value)intSets quantity with animation
QuantitySelectorExample.cs using UnityEngine ;
using Evo . UI ;
public class QuantitySelectorExample : MonoBehaviour
{
public QuantitySelector productQuantity ;
void Start ()
{
// Configure range
productQuantity.minQuantity = 1 ;
productQuantity.maxQuantity = 99 ;
// Listen for changes
productQuantity.onValueChanged. AddListener ( quantity =>
{
Debug. Log ( $"Quantity changed to: { quantity } " );
UpdatePrice (quantity);
});
// Set quantity programmatically
productQuantity. SetQuantity ( 5 );
// Get current value
int currentQty = productQuantity.CurrentQuantity;
Debug. Log ( $"Current quantity: { currentQty } " );
// Control without animation
productQuantity. SetQuantity ( 10 , false );
}
void UpdatePrice ( int quantity )
{
float pricePerUnit = 9.99f ;
float totalPrice = quantity * pricePerUnit;
Debug. Log ( $"Total: $ { totalPrice : F2 } " );
}
}