Skip to content

U-Selector syntax

U-Selector finds GameObjects the way CSS selectors find HTML elements. query_objects, wait_for_selector, assert_ui_state, simulate_input (ui_click), batch_modify and the steps of run_e2e_test all take one.

#Player by name
#Enemy* name with wildcards (* any text, ? one character)
.Camera by component type
/Canvas/Menu/PlayButton by hierarchy path
[tag=Player] by attribute
.Enemy[tag=Boss] component type and attribute
ui:#StartButton UI Toolkit element by name
ui:.menu-item UI Toolkit elements by USS class
ui:Button UI Toolkit elements by type

Matches the GameObject name exactly. * and ? make it a pattern: #Enemy* (starts with), #*Spawner (ends with), #*Boss* (contains). A selector without a prefix is also treated as a name.

Matches GameObjects that have a component of that type, such as .Camera, .Rigidbody or your own .EnemyController.

Matches by hierarchy path from a root object.

Operators: =, !=, >, <. Attribute names:

Attribute Value
name GameObject name
tag Tag
layer Layer number
active Active in the hierarchy
activeSelf Own active flag
anything else A public property of one of the object’s components, e.g. [enabled=false]

Combine with a type to narrow the search: .Enemy[tag=Boss].

A ui: prefix searches the visual trees of all UIDocuments in the scene: ui:#name, ui:.uss-class or a type name such as ui:Button.