Skip to main content

manage_input

Auto-generated from the Python tool registry. Do not hand-edit outside <!-- examples:start --><!-- examples:end --> blocks — the generator (tools/generate_docs_reference.py) will overwrite them.

Group: testing  ·  Module: services.tools.manage_input

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Simulate bounded input in Unity Play Mode. status reports capabilities and held controls. ui_click dispatches pointer events directly to a uGUI target such as a button, using its scene instance ID or exact root hierarchy path, independently of the raw input backend. Direct dispatch does not test raycast occlusion. Observe the handler's gameplay effect separately. key/mouse/touch/gamepad/wheel require com.unity.inputsystem and Input System or Both handling. gamepad control is a named stick, trigger or button; sticks use value [x,y] in -1..1, triggers use scalar value 0..1 and buttons omit value. Release omits value and returns neutral. wheel delta [x,y] in -10000..10000 is dispatched once, preserving held mouse buttons. player_status(target) reads actual PlayerInput action/device resolution. pair_player(target) adds only a neutral MCP-owned gamepad to one selected player; existing paired devices and control scheme remain. release_player(target) ends that owned device lease. press holds for 1..36000 game input updates then releases; use release for an earlier release. touch_id 1..10 permits concurrent contacts across calls; move preserves the original release deadline. release_all removes only MCP virtual devices. Active input updates renew a 30-second inactivity lease up to 1 hour; play exit/reload cleans devices. Pause also cleans pairing; release_player/release_all remain callable while paused. PlayerInput eligibility does not guarantee gameplay handling. Old Input Handling supports uGUI ui_click and legacy observation through manage_scenario_recording. status exposes the active handling mode, observation backend and raw replay limits. UnityEngine.Input has no public raw-state injection API; Both-mode virtual devices only affect Input System consumers. No OS input is sent.

Parameters​

NameTypeRequiredDescription
actionLiteral['status', 'player_status', 'pair_player', 'release_player', 'ui_click', 'key', 'mouse', 'touch', 'gamepad', 'wheel', 'release_all']yesRead status/player_status; explicitly pair/release a player or simulate bounded input
targetint | str | None—ui_click scene instance ID or exact root hierarchy path
keystr | None—Input System Key enum name, for example A, Space or LeftShift
stateLiteral['press', 'release', 'move']—press or release; mouse/touch also support move
framesint—Hold for this many game Input System updates (dynamic or fixed)
positiontuple[float, float] | None—Screen pixel x,y; required for mouse move and touch press/move
buttonLiteral['left', 'right', 'middle']—Mouse button
touch_idint—Independent touch contact ID (1..10)
controlLiteral['leftStick', 'rightStick', 'leftTrigger', 'rightTrigger', 'buttonSouth', 'buttonNorth', 'buttonEast', 'buttonWest', 'leftShoulder', 'rightShoulder', 'leftStickPress', 'rightStickPress', 'start', 'select', 'dpadUp', 'dpadDown', 'dpadLeft', 'dpadRight'] | None—Named gamepad stick, trigger or button
valuefloat | tuple[float, float] | None—Stick [x,y] or trigger scalar; omit for buttons and release
deltatuple[float, float] | None—One-shot wheel delta [x,y]
deviceLiteral['gamepad'] | None—Explicit pairing device; defaults to owned gamepad
unity_instancestr | int | None—Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance.

Returns​

A dict containing the Unity response. The exact shape depends on the action.

Examples​

Inspect capabilities in the selected Unity instance before simulating input:

{"action":"status"}

Dispatch a direct uGUI click to an inspected scene instance ID in running Play Mode:

{"action":"ui_click","target":-19340}

Hold an Input System key for three game input updates, then let the tool release it:

{"action":"key","key":"Space","state":"press","frames":3}

The key example requires the optional Input System package and compatible handling mode. A direct UI click bypasses physical hit testing; inspect the application's response separately. Use release_all to release MCP virtual devices early or while paused.