UI Toolbox logoUI Toolbox
Support

ChoiceWheel

ChoiceWheel in UIToolbox is a wheel of short choices around a center, as the dialogue wheel of a role-playing game, the radio wheel of a squad or the Friendly, Investigate and Hostile wheel of an approach. Each choice has a wedge of the ring, and its text shows outside the ring, on the side of its wedge. A tone gives a choice its color and glyph; a locked choice shows a padlock and its reason, such as "Needs 4 Charm". The center shows the question or the speaker, with an arrow at the highlighted choice. The pointer, a stick, the arrows and the number keys pick a choice, and StartTimer makes a timed choice. A DialogueBox shows its choices in a wheel when its Wheel is set.

A ChoiceWheel around the smith Brom with five choices in their tones and a Haggle choice locked by Needs 4 Charm, over a dialogue boxA ChoiceWheel around the smith Brom with five choices in their tones and a Haggle choice locked by Needs 4 Charm, over a dialogue box

Video tutorial: Dialogue box. All videos: Video tutorials.

<tb:ChoiceWheel
    name="wheel"
    center-text="Who sent you?"
    choices="We mean no harm.,Answer me.,Who are you?" />
var wheel = root.Q<ChoiceWheel>("wheel");
wheel.CenterText = "Who sent you?";
wheel.Items = new List<ChoiceItem>
{
    new("We mean no harm.") { Tone = ChoiceTone.Friendly },
    new("Answer me.") { Tone = ChoiceTone.Hostile },
    new("Lie.") { Locked = true, Detail = "Needs 4 Charm" },
    new("Who are you?") { Tone = ChoiceTone.Investigate },
};
wheel.Chosen += index => Debug.Log(wheel.Items[index].Text);
wheel.Focus();

// The player has 8 seconds; then "Answer me." is picked
wheel.StartTimer(8, 1);

The items are ChoiceItem values, as in ChoiceMenu. The first choice is right of the top and the others follow clockwise, so two choices sit left and right, and six sit three on each side. A choice with no text leaves its wedge empty, so the other choices keep their places: four choices with two empty ones sit as six. Tone is Neutral (no glyph), Friendly (a heart), Investigate (a magnifying glass), Hostile (a lightning bolt), Deceive (a mask) or Leave (an arrow out of a door); an Icon shows in the wedge in place of the glyph. A locked choice takes the highlight, so the player reads its reason, but a pick shakes it and raises Refused. A locked choice with no Detail says "Locked", and its reason is also its tooltip. A disabled choice shows dimmed and is passed over. An explored choice (ChoiceItem.Explored, or SetExplored(index), or the explored attribute) shows dimmed in a muted text color but can still be picked, so the player sees which questions are already asked; DialogueBox marks each picked item explored. The wheel reads the items when Items is set, so after a change to Locked, Enabled or Detail, set Items again.

Settings

Setting (UXML) Type Default Does
choices list of strings empty The choices, as text. An empty choice leaves its wedge empty. Items in code sets the tones, icons, details and the disabled and locked states.
center-text string empty The text in the middle of the ring, such as the question or the name of the speaker.
inner-radius float 0.6 The size of the middle of the ring, as a share of its radius, from 0.2 to 0.9.
show-numbers bool false Each of the first nine choices shows its number, and the number keys pick them. An empty wedge has no number.
cancel-choice int -1 The choice that Escape or the gamepad East button picks, such as "Goodbye.". -1 lets Escape go on to the parent, such as a window.
animate bool true Fades the highlight between the wedges and turns the arrow. Off, they change at once.
explored list of numbers empty The numbers of the explored choices, from 0 at the top. They show dimmed. ChoiceItem.Explored and SetExplored do the same in code.

HighlightedIndex gets or sets the highlighted choice, IsTimed and TimeLeft give the timer.

Methods

Method Does
StartTimer(seconds, timeoutChoice) Starts a timer. An arc around the ring runs out, then timeoutChoice is picked, or Chosen occurs with -1 when it is -1. A pick stops the timer.
StopTimer() Stops the timer without a pick.
Choose(index) Picks a choice and highlights it. False for an empty, disabled or locked choice.
Point(direction) Highlights the choice in the direction of a stick, with y up. A direction shorter than 0.5 keeps the highlight, so the choice stays when the stick goes back.
ChoiceAt(localPosition) The choice in the direction of a point of the wheel, or -1 in the middle of the ring.
AngleOf(index) The middle of the wedge of a choice, in degrees clockwise from the top.

Events

Event When
Chosen(int) The player picks a choice, with its index. -1 when the timer runs out with no timeout choice: the player said nothing.
HighlightChanged(int) The highlight moves, with the index of the new choice, or -1. Play a tick or show a hint here.
Refused(int) The player tries to pick a locked choice, with its index.

Mouse and keyboard

Input Does
Pointer Highlights the choice in its direction: on its wedge, on its text or past the ring.
Click, Enter, Space, gamepad South Picks the highlighted choice.
Left stick, with Point Highlights the choice the stick points at.
Up, Down, D-pad Go to the next choice along the side of the wheel.
Left, Right, D-pad Go across to the choice on the other side, or along the side when it is already there.
Tab, Shift+Tab Go around the wheel.
1 to 9, also on the keypad Picks that choice, when show-numbers is on.
Escape, gamepad East Picks cancel-choice, or goes on to the parent when it is -1.

The wheel reads the stick from your input code: call Point with its direction each frame while the wheel shows. While the stick is out of the dead zone, the wheel ignores the navigation moves that the stick also sends.

Performance

Play a conversation in a wheel

Give a DialogueBox a wheel, and Ask and Play show their choices in it in place of the menu. The wheel can be anywhere in the panel, such as in the middle of the screen over the scene: the box shows it while the choices show, gives it the focus, and hides it after a pick. The timer of a timed choice runs on the wheel. Set Wheel back to null to show the choices in the menu again.

var box = root.Q<DialogueBox>("dialogue");
box.Wheel = root.Q<ChoiceWheel>("wheel");
box.Say("Rowan", "We need to talk about the plan.");
box.Ask(new List<ChoiceItem>
{
    new("I trust you.") { Tone = ChoiceTone.Friendly },
    new("What changed?") { Tone = ChoiceTone.Investigate },
    new("Not now.") { Tone = ChoiceTone.Hostile },
});

Styling

Class Element
tb-choice-wheel The wheel, 600 by 280 px. With --timed while the timer runs.
tb-choice-wheel__ring The ring, 150 px. Its width and height set the size of the ring; the wheel centers it.
tb-choice-wheel__center The label in the middle of the ring.
tb-choice-wheel__icon The icon of a choice in its wedge.
tb-choice-wheel__choices The layer that holds the texts of the choices.
tb-choice-wheel__choice The text of a choice, outside the ring. With --right, --left, --top or --bottom for its side, --highlighted, --locked, --explored, --disabled, and --friendly, --investigate, --hostile, --deceive or --leave for its tone.
tb-choice-wheel__number, __body, __text, __detail The parts of a choice: its number, the column of its text and detail, and the reason of a locked choice.
Variable Default Colors
--tb-choice-wheel-wedge --tb-color-surface-alt A wedge that is not highlighted.
--tb-choice-wheel-center --tb-color-surface The middle of the ring.
--tb-choice-wheel-line --tb-color-border The lines between the wedges and the rim.
--tb-choice-wheel-glyph --tb-color-accent-text The glyph in the highlighted wedge.
--tb-choice-wheel-timer --tb-color-warning The arc of the timer.
--tb-choice-wheel-neutral, -friendly, -investigate, -hostile, -deceive, -leave accent, success, warning, danger, violet, muted text The tones: the highlighted wedge, the glyphs and the bar of the highlighted text.

A bigger wheel with a blue Investigate tone:

.tb-choice-wheel {
    width: 760px;
    height: 360px;
    --tb-choice-wheel-investigate: #4aa3ff;
}
.tb-choice-wheel__ring { width: 200px; height: 200px; }

The ChoiceWheelDemo scene shows a conversation with a smith in a dialogue wheel, with a locked choice and a timed choice, a Friendly, Investigate and Hostile wheel that picks the approach to a guard, a radio wheel of squad orders on the stick, and the looks of the wheel.

Used in: Parley, a cinematic conversation where a List / Wheel button switches the choices between the wheel and a ChoiceMenu.