UI Toolbox logoUI Toolbox
Support

QuickSelect

QuickSelect is the d-pad quick bar of a console game: a cross of four AbilitySlots, one for each direction of the d-pad. Each direction holds a list of items, and its slot shows the default item. A tap uses the default item. A hold opens a strip of the items of that direction to pick another default, or uses the item in another way, such as throw instead of drink. View opens a wheel of every item to put an item on a direction. With no settings, it reads the d-pad, the keys 1 to 4, View and Tab.

Two potions, a wand and a bow on the four directions of a crossTwo potions, a wand and a bow on the four directions of a cross

The QuickSelect demo

Demo scene: QuickSelectDemo.unity.

How to add a cross:

<tb:QuickSelect name="quick" hold-time="300" />

How to fill it and answer the uses:

var quick = root.Q<QuickSelect>("quick");
var potion = new QuickSelectItem("potion", potionIcon, "Potion", 3);
var bomb = new QuickSelectItem("bomb", bombIcon, "Bomb", 5);
quick.Add(QuickSelectDirection.Down, potion);
quick.Add(QuickSelectDirection.Down, bomb);
quick.Used += (direction, item) =>
{
    item.Count--;
    quick.StartCooldown(item, 2);
};

The first item of a direction is its default. Set Count, Usable or Icon of an item and each slot that shows it follows. A cooldown belongs to the item, so it shows on every direction and in the strip.

How to throw on a hold instead of picking:

quick.SetHoldAction(QuickSelectDirection.Right,
    QuickSelectHoldAction.Alternate);
quick.AlternateUsed += (direction, item) => Throw(item);

How to offer the rest of the bag on the wheel, with the game slowed:

quick.TimeWhileOpen = QuickSelectTime.Slow;
foreach (var item in bag) quick.AddWheelItem(item);
quick.Assigned += (direction, item) => Save(direction, item);

How to read the game's own Input System actions:

quick.Actions = new[] { up, right, down, left };
quick.AssignAction = openWheel;
Member Description
HoldTime (hold-time) The milliseconds a direction is held before the hold action. Default 300.
HoldAction (hold-action) A QuickSelectHoldAction for every direction: Pick (the default) opens the strip, Alternate raises AlternateUsed, None uses the item on the release.
TimeWhileOpen (time-while-open) A QuickSelectTime while the wheel is open: Run (the default), Slow or Pause. The strip never changes the time.
SlowScale (slow-scale) The share of the game time with Slow, 0 to 1. Default 0.25.
AssignWheel (assign-wheel) True opens the wheel on View or Tab. False leaves that binding to the game.
ListenKeys (listen-keys) The control reads its input. False leaves the input to you; call Press and Release.
Keys (keys) A QuickSelectKeys: Slots (the default) puts the key or button on each slot; Center puts one d-pad glyph in the middle of the cross and no key on the slots.
Add, Remove, Clear The items of a direction.
ItemsOf, DefaultOf, SetDefault The items and the default item of a direction. SetDefault raises no event.
SetHoldAction, HoldActionOf The hold action of one direction.
AddWheelItem, WheelItems Items the wheel offers besides the items on the directions.
Assign(direction, item) Puts an item on a direction as its default.
StartCooldown, SetCooldown, ClearCooldown The cooldown of an item, on every slot that shows it.
Press, Release, Step, Point Drive the control from your own input.
OpenWheel, CloseWheel, Cancel Open and close the wheel; Cancel also closes the strip.
IsOpen, IsStripOpen, IsWheelOpen The strip or the wheel shows. Read no stick in your game then.
OwnsInput True while a direction is held, the strip or the wheel shows, or one closed in this frame. Skip your own read of B or Escape then, so the press that closes the wheel does not open your menu.
SlotOf(direction), Wheel The slot of a direction and the RadialMenu of the wheel.
Actions, AssignAction Input System only: the game's actions in place of the d-pad, the keys 1 to 4, View and Tab. The slots show their bindings.
Used A tap used the default item of a direction.
AlternateUsed A hold with Alternate used the item.
DefaultChanged The strip set another default item.
Assigned The wheel put an item on a direction.
Opened, Closed The strip or the wheel opened or closed.

Tips:

Styling

Class Element
tb-quick-select The cross.
tb-quick-select__dpad The d-pad glyph in the middle of the cross, with Keys = Center.
tb-quick-select--open The strip or the wheel shows.
tb-quick-select__slot A slot of the cross, with --up, --right, --down and --left.
tb-quick-select__slot--held The slot of the held direction.
tb-quick-select__more The dot on a slot whose direction holds more than one item.
tb-quick-select__strip The strip, with --up, --right, --down and --left.
tb-quick-select__pick A slot of the strip.
tb-quick-select__pick--picked The highlighted slot of the strip.
tb-quick-select__wheel The wheel.

The slots use the classes and variables of AbilitySlot, and the wheel those of RadialMenu.

.my-hud .tb-quick-select__strip {
    background-color: rgba(0, 0, 0, 0.7);
}

SVG: The icon of an item is a Background. An SVG imported as a VectorImage works as well as a texture. See Pictures: PNG or SVG.