UI Automation
Find, inspect, and interact with uGUI / UI Toolkit elements via unity-cli. This skill is the UI-focused complement to unity-playmode-testing (full runtime control).
Use When
- The user wants to locate UI elements by name or type.
- The task requires inspecting UI state before or after interaction.
- The user wants to click UI elements, set values, or run a short UI input sequence.
Do Not Use When
- The task is general Play Mode setup with no UI targeting requirement; use
unity-playmode-testing. - The request authors UI prefabs or scene hierarchy; use
unity-scene-createorunity-prefab-workflow.
Preferred Flow
- Find the target with
namePatternorelementType. - Inspect current state before acting (visibility, interactability).
- Perform one interaction at a time and re-check state when sequence matters.
- Combine with
unity-playmode-testingonly when the UI depends on runtime state.
unity-cli raw find_ui_elements --json '{"namePattern":"Start","includeInactive":true}'
unity-cli raw get_ui_element_state --json '{"elementPath":"/Canvas/StartButton"}'
unity-cli raw click_ui_element --json '{"elementPath":"/Canvas/StartButton"}'
unity-cli raw set_ui_element_value --json '{"elementPath":"/Canvas/NameInput","value":"Player1"}'
Examples
- "Find the start button and click it."
- "Read the current value of
/Canvas/NameInputand then set it toPlayer1." - "Run a short slider interaction sequence in the active UI."
References
- runtime-checklist.md: connection and instance prerequisites.
- ui-test-flow.md: safer locate-inspect-interact sequence for UI testing.