Skip to main content

UI and interaction

Clicking objects​

Override Interact() in a script on an object with a collider. Players click it with the crosshair on desktop. In VR they point the laser at it or touch it with a hand, and press grip. The object is outlined while it can be clicked, and the text shown when pointing at it is the script's InteractionText. The object doesn't need a Rigidbody: if it has none, StageTime adds a kinematic one so hands can touch it, and moving it by its Transform still works.

UI buttons​

Use normal Unity UI on a world-space Canvas inside your world:

  1. UI → Canvas, Render Mode: World Space, scaled down (e.g. 0.001).
  2. Add Buttons, Sliders, Toggles and TextMeshPro text as usual.
  3. In a Button's On Click (), drag in the object with your script and pick the method, e.g. Counter → Increment. Any public method with no parameters works.
  4. Input fields and dropdowns work the same way: pick your method in On End Edit, On Submit or On Value Changed, then read the new value from the component (see below).

There is nothing else to add: the builder makes every canvas with buttons clickable (it adds ST Interactable Canvas) and turns each On Click into a call to your script.

tip

On Click targets must be your scripts' public, parameterless methods. Other targets (for example GameObject.SetActive) are rejected by the builder: call them from a script method instead.

Reading UI values​

Scripts can read and set UI state directly:

public Slider volume;
public Toggle music;

public void ApplySettings()
{
audioSource.volume = volume.value;
audioSource.mute = !music.isOn;
}

Text input​

TextMeshPro Input Field and legacy Input Field both work on world canvases. Scripts read and set text, and SetTextWithoutNotify(text) changes it without raising the field's events. interactable, readOnly, characterLimit, isFocused, ActivateInputField() and DeactivateInputField() are available too.

public TMP_InputField search;

// Input Field → On End Edit → CatalogueSearch.Search
public void Search()
{
string text = search.text.Trim();
if (text.Length == 0) return;
// ...
}

Players type with the keyboard that suits their device. StageTime adds what each canvas needs when the world loads:

DeviceKeyboard
Desktopthe computer keyboard; walking and jumping pause while a field has focus
PC VR, Apple Vision ProStageTime's on-screen keyboard, shown on the field's canvas
Quest, Pico, phonesthe device's system keyboard

Leave room on the canvas: the on-screen keyboard covers its lower part.

TextMeshPro Dropdown and legacy Dropdown both work. Scripts read and set value (the selected option's index), SetValueWithoutNotify(index) and captionText. Scripts cannot use the options list, so fill and read the options with DropdownOptions:

public TMP_Dropdown playlist;

void Start() => DropdownOptions.Set(playlist, new[] { "All items", "Favourites", "New" });

// Dropdown → On Value Changed → Playlists.Changed
public void Changed()
{
string name = DropdownOptions.Get(playlist, playlist.value);
// ...
}

DropdownOptions.Count(dropdown) gives the number of options; a dropdown holds up to 256. The catalogue browser example uses search fields and a list dropdown.