Skip to content

Buttons

caxawu edited this page Aug 17, 2020 · 1 revision

Buttons

Buttons are physical objects in the scene that the player can interact with via the little sphere floating above the right controller. The player can hover over buttons by moving the right controller so the sphere collides with the button. On hover, the button, selector sphere, and controller change color and the right controller triggers haptic feedback. While hovering, the player can press the button by pressing the trigger on the right controller.

Set up a new button

To interact with a new button, either drag in a button prefab into your scene from Assets -> Prefabs -> Dashboard -> Button or attach Button.cs to the gameobject that you want to be a button.

Button.cs

Parameters

This script reveals multiple different parameters in the inspector:

Button Text: What you want the button label to be.
Right Controller: A reference to the RightHandAnchor to trigger haptics and color changes.
Default Button Color: The color that you want the button to be.
Hover Button Color: The color you want the button to be when you are hovering over it with your right controller.
Hover/Selection Haptic Frequency/Amplitude/Duration: Refers to the haptic parameters triggered on the right controller.

Events

Button.cs evokes two events:
OnClick: This event in invoked when the selector sphere on the right hand is hovering over a button and the trigger button is pressed.
onButtonEnter: This event is invoked when the selector sphere on the right hand is hovering over a button.