uloop-execute-dynamic-code
Task
Run focused C# snippets in the active Unity Editor with uloop execute-dynamic-code.
For basic selected GameObject discovery or property inspection, use find-game-objects --search-mode selected before this tool. Use this tool after the built-in inspection tools are not enough or when you need to modify Unity state.
This tool can inspect reachable Unity state — GameObjects, components, public properties, static values, method results — but it cannot read local variables or intermediate calculations inside an already-running method. When those values matter, follow the uloop-pause-point skill: a pause point's CapturedVariables carries the locals, parameters, and instance fields at that line with no code edit or recompile, and while Unity stays paused UloopPausePoint.TryGetCapturedValue(name) gives this tool live captured references. That skill also covers the reverse combination — registering an EditorApplication.update watcher from this tool that freezes Unity on the first frame a runtime condition holds. Never poll or sleep inside a snippet; the body runs synchronously on the main thread.
Live state injection: when a running PlayMode session is merely in the wrong state — a stuck end-to-end scenario, a camera angle a raycast can never hit, a private flag blocking the path under test — fix the state instead of the code: write the field directly from this tool (reflection reaches private fields) and steer the session onward. Nothing recompiles and no domain reload happens, so the session's in-memory state survives intact. The snippet is a one-off diagnostic that never lands in source files, so project rules restricting reflection in production code are not violated.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
--code |
string | - | Inline C# statements to execute. Direct statements only; return is optional, and using directives may appear at the top of the snippet. |
--parameters |
object | - | Shell-quoted JSON object literal for reusing a snippet with varying data or keeping values outside the code. Values are exposed as parameters["param0"], parameters["param1"], and so on. Omit for most snippets; never pass a JSON string value. |
--wait-for-domain-reload |
flag | - | Wait for Domain Reload recovery after snippets that intentionally trigger Unity script reload or import work. Omit for normal inspection and editor-state workflows. |
--yield-to-foreground-requests |
flag | - | Allow foreground requests to preempt this execution |