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 attributeui:#StartButton UI Toolkit element by nameui:.menu-item UI Toolkit elements by USS classui:Button UI Toolkit elements by typeName — #Name
Section titled “Name — #Name”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.
Component — .Type
Section titled “Component — .Type”Matches GameObjects that have a component of that type, such as .Camera, .Rigidbody or your own .EnemyController.
Path — /Parent/Child
Section titled “Path — /Parent/Child”Matches by hierarchy path from a root object.
Attribute — [name op value]
Section titled “Attribute — [name op value]”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].
UI Toolkit — ui:
Section titled “UI Toolkit — ui:”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.