Inventool Quantity Prompt

🔢 InventoolQuantityPrompt Class

A pop-up element that prompts the user for a numeric quantity.

Namespace: Esper.Inventool.UI Access: public Type: class Inherits: CrossInputSupportedWindow


📦 Fields

Access
Field
Type
Description

protected

minQuantity

float

The minimum quantity allowed.

protected

maxQuantity

float

The maximum quantity allowed.

protected

currentQuantity

float

The current quantity selected by the user.

protected

root

VisualElement

The root UI element for the prompt.

protected

hiddenCloseButton

Button

Full-screen invisible close button.

protected

titleLabel

Label

The prompt title label.

protected

targetGraphic

VisualElement

Element displaying the target graphic.

protected

quantitySliderInt

SliderInt

Integer-mode quantity slider.

protected

quantityFieldInt

IntegerField

Integer-mode quantity input field.

protected

quantitySliderFloat

Slider

Float-mode quantity slider.

protected

quantityFieldFloat

FloatField

Float-mode quantity input field.

protected

leftButton

Button

The left action button.

protected

rightButton

Button

The right action button.

protected

leftButtonIconElement

VisualElement

Icon element for the left button.

protected

rightButtonIconElement

VisualElement

Icon element for the right button.

protected

leftButtonLabel

Label

Label for the left button.

protected

rightButtonLabel

Label

Label for the right button.

protected

spacing

VisualElement

Spacing element between buttons.

protected

leftButtonAction

Action<float>

Callback for left button click.

protected

rightButtonAction

Action<float>

Callback for right button click.

protected

rightButtonTextSetter

Func<float, string>

Function to update right button label based on currentQuantity.

protected

quantityMode

QuantityMode

Current quantity input mode (Integer or Float).


🔍 Properties

Access
Property
Type
Description

public

LeftButtonColor

Color

Background color of the left button.

public

RightButtonColor

Color

Background color of the right button.

public static

Instance

InventoolQuantityPrompt

Active singleton instance.


🧰 Methods

Access
Method
Returns
Description

protected override

Awake()

void

Initialize singleton, cache UI elements, and register callbacks.

public virtual

Open(string title, int minQuantity, int maxQuantity, Action<float> leftButtonAction = null, Action<float> rightButtonAction = null, bool showLeftButton = true, bool showRightButton = true, string leftButtonText = "Cancel", string rightButtonText = "Confirm", Sprite targetGraphic = null, Sprite leftButtonIcon = null, Sprite rightButtonIcon = null, Func<float,string> rightButtonTextSetter = null)

void

Display integer-mode quantity prompt with specified settings.

public virtual

Open(string title, float minQuantity, float maxQuantity, Action<float> leftButtonAction = null, Action<float> rightButtonAction = null, bool showLeftButton = true, bool showRightButton = true, string leftButtonText = "Cancel", string rightButtonText = "Confirm", Sprite targetGraphic = null, Sprite leftButtonIcon = null, Sprite rightButtonIcon = null, Func<float,string> rightButtonTextSetter = null)

void

Display float-mode quantity prompt with specified settings.

protected virtual

UpdateRightButtonText()

void

Refresh right button label using rightButtonTextSetter.

protected virtual

UpdateQuantityElements()

void

Sync sliders and fields to reflect currentQuantity.

public virtual

Close()

void

Hide and disable prompt, register closing transition callback.

protected virtual

OnClosed(TransitionEndEvent endEvent)

void

Finalize prompt hide after transition and invoke close callbacks.


🧩 Nested Types

public enum QuantityMode

Name
Description

Integer

Use integer slider and field.

Float

Use float slider and field.


Active Instance

You can get the active InventoolQuantityPrompt instance with InventoolQuantityPrompt.Instance. Ensure there's an instance of it in your scene before using this field.

Open

The Open method has many parameters you can use to customize what's displayed on the confirm prompt.

Name
Description
Type

title

The prompt title or the localized string key if you're using localization.

string

minQuantity

The minimum quantity.

float

maxQuantity

The maximum quantity.

float

leftButtonAction

The left button on-click action.

Action<float>

rightButtonAction

The right button on-click action.

Action<float>

showLeftButton

If the left button should be displayed.

bool

showRightButton

If the right button should be displayed.

bool

leftButtonText

The left button text or the localized string key if you're using localization.

string

rightButtonText

The right button text or the localized string key if you're using localization.

string

targetGraphic

A sprite that represents the target of the action.

Sprite

leftButtonIcon

The left button icon.

Sprite

rightButtonIcon

The right button icon.

Sprite

rightButtonTextSetter

The right button text setter.

Func<float, string>

// Open with range from 0 to 100
InventoolQuantityPrompt.Instance.Open("My Title", 0, 100);

Close

InventoolQuantityPrompt.Instance.Close();

Last updated