Guides
These docs are for v3.2.0. Click to read the latest docs for v3.3.0.

Radial Menu

Overview

This adds a UI element into the world space that can be dropped into a Controller object and used to create and use Radial Menus from the touchpad.

If the RadialMenu is placed inside a controller, it will automatically find a VRTK_ControllerEvents in its parent to use at the input. However, a VRTK_ControllerEvents can be defined explicitly by setting the Events parameter of the Radial Menu Controller script also attached to the prefab.

The RadialMenu can also be placed inside a VRTK_InteractableObject for the RadialMenu to be anchored to a world object instead of the controller. The Events Manager parameter will automatically be set if the RadialMenu is a child of an InteractableObject, but it can also be set manually in the inspector. Additionally, for the RadialMenu to be anchored in the world, the RadialMenuController script in the prefab must be replaced with VRTK_IndependentRadialMenuController. See the script information for further details on making the RadialMenu independent of the controllers.

Inspector Parameters

  • Buttons: An array of Buttons that define the interactive buttons required to be displayed as part of the radial menu.
  • Button Prefab: The base for each button in the menu, by default set to a dynamic circle arc that will fill up a portion of the menu.
  • Generate On Awake: If checked, then the buttons will be auto generated on awake.
  • Button Thickness: Percentage of the menu the buttons should fill, 1.0 is a pie slice, 0.1 is a thin ring.
  • Button Color: The background colour of the buttons, default is white.
  • Offset Distance: The distance the buttons should move away from the centre. This creates space between the individual buttons.
  • Offset Rotation: The additional rotation of the Radial Menu.
  • Rotate Icons: Whether button icons should rotate according to their arc or be vertical compared to the controller.
  • Icon Margin: The margin in pixels that the icon should keep within the button.
  • Is Shown: Whether the buttons are shown
  • Hide On Release: Whether the buttons should be visible when not in use.
  • Execute On Unclick: Whether the button action should happen when the button is released, as opposed to happening immediately when the button is pressed.
  • Base Haptic Strength: The base strength of the haptic pulses when the selected button is changed, or a button is pressed. Set to zero to disable.
  • Menu Buttons: The actual GameObjects that make up the radial menu.

Class Methods

HoverButton/1

public virtual void HoverButton(float angle)

  • Parameters
  • float angle - The angle on the radial menu.
  • Returns
  • none

The HoverButton method is used to set the button hover at a given angle.

ClickButton/1

public virtual void ClickButton(float angle)

  • Parameters
  • float angle - The angle on the radial menu.
  • Returns
  • none

The ClickButton method is used to set the button click at a given angle.

UnClickButton/1

public virtual void UnClickButton(float angle)

  • Parameters
  • float angle - The angle on the radial menu.
  • Returns
  • none

The UnClickButton method is used to set the button unclick at a given angle.

ToggleMenu/0

public virtual void ToggleMenu()

  • Parameters
  • none
  • Returns
  • none

The ToggleMenu method is used to show or hide the radial menu.

StopTouching/0

public virtual void StopTouching()

  • Parameters
  • none
  • Returns
  • none

The StopTouching method is used to stop touching the menu.

ShowMenu/0

public virtual void ShowMenu()

  • Parameters
  • none
  • Returns
  • none

The ShowMenu method is used to show the menu.

GetButton/1

public virtual RadialMenuButton GetButton(int id)

  • Parameters
  • int id - The id of the button to retrieve.
  • Returns
  • RadialMenuButton - The found radial menu button.

The GetButton method is used to get a button from the menu.

HideMenu/1

public virtual void HideMenu(bool force)

  • Parameters
  • bool force - If true then the menu is always hidden.
  • Returns
  • none

The HideMenu method is used to hide the menu.

RegenerateButtons/0

public void RegenerateButtons()

  • Parameters
  • none
  • Returns
  • none

The RegenerateButtons method creates all the button arcs and populates them with desired icons.

AddButton/1

public void AddButton(RadialMenuButton newButton)

  • Parameters
  • RadialMenuButton newButton - The button to add.
  • Returns
  • none

The AddButton method is used to add a new button to the menu.

Example

VRTK/Examples/030_Controls_RadialTouchpadMenu displays a radial menu for each controller. The left controller uses the Hide On Release variable, so it will only be visible if the left touchpad is being touched. It also uses the Execute On Unclick variable to delay execution until the touchpad button is unclicked. The example scene also contains a demonstration of anchoring the RadialMenu to an interactable cube instead of a controller.