# AI UI handoff for Godot and Unity: from design to game

> A useful AI UI handoff includes the actual UI document, a list of events and data paths, reference renders, runtime instructions and a way to validate edits. The agent connects those interfaces to game code; the team verifies behavior and rendering in the target engine.

Source: https://envyui.com/blog/ai-ui-handoff-godot-unity
Published: 2026-11-07

The difficult part of UI handoff is not sending a screenshot. It is communicating what the screen does when the player selects a slot, changes a setting or runs out of health. An AI coding agent needs that behavior expressed in terms it can connect to your game.

## Separate the design file from the game boundary

The design describes screens, visual states and layout. The boundary describes data supplied by the game and events sent back. Keep the boundary small and explicit. For a pause menu, that might mean `settings.master_volume` going into the UI and `resume_requested` coming out.

Do not ask an agent to infer those names from pixels. Provide a [UI contract](/blog/game-ui-contract-ai-agents), sample values and the intended behavior when an action fails. A screenshot is a reference for appearance, not a complete specification.

## Assemble a handoff package

| Artifact | What the agent uses it for |
|---|---|
| UI document and runtime | Load the intended screens in the target game |
| Events and data contract | Connect the game without guessing names or types |
| Screen renders and scenarios | Compare appearance with representative states |
| Integration instructions | Locate files, runtime APIs and project conventions |
| Validator and tests | Catch malformed edits and verify actual behavior |

Envy's [AI handoff package](/docs/handoff) includes the document, contract, runtime instructions and validator, plus generated starting controllers for Godot, Unity and the web. Screen renders are optional. Its `MANIFEST.json` lists package files; check it before passing the package to an agent, particularly when reference renders matter to your review. Game-specific integration tests still need to be supplied by the team.

## Give the agent a bounded integration task

Choose one screen and one target engine first. Tell the agent to read the project instructions and contract, load the document using the supplied runtime, implement each relevant event and supply real data from the game. Require it to identify placeholders or unhandled cases.

For Godot, Envy's runtime builds native Control nodes. For Unity, it builds UI Toolkit elements. Both load the UI document at runtime. The game-side code still needs to connect its systems to the listed events and paths. Consult the [Godot](/docs/godot) or [Unity](/docs/unity) integration instructions for supported versions and installation steps.

The names differ across engines even when the contract is shared:

| Integration step | Godot runtime | Unity runtime |
|---|---|---|
| Load the document | `document_path` or `load_document()` | `LoadDocument()` or `LoadFile()` |
| Send game data to the UI | `set_data(path, value)` | `SetData(path, value)` |
| Receive a UI event | `ui_event(event, payload)` signal | `UiEvent` event |
| Start controller focus | `focus_first_button()` | `FocusFirstButton()` |
| Change language | `set_locale(locale)` | `SetLocale(locale)` |

For a health display, the contract might identify `player.hp` as a number. Set it from the game state when the screen starts, update it when health changes and test zero and missing values. For an event such as `resume_requested`, connect the runtime event to the pause system and verify the game actually resumes. Those example names are project decisions, not built-in event names.

Do not accept a generated `pass` or TODO as a working event handler. For example, a “New hunt” action is complete only when the game has performed the expected transition and handles failure or repeated input as your design requires.

## Test the contract and the picture

Run the document validator, then exercise the game. For every important screen, check the initial data, a changed value, the primary action and an invalid or missing value. Test keyboard or controller navigation if the game supports it. Save test output and note which checks were manual.

Compare the target-engine view with the provided render at the same viewport and sample data. Envy's [runtime differences](/docs/differences) include font rendering, clipping, focus search and some effects. A shared document reduces the amount to rebuild; it does not make every engine draw identical pixels.

## Handle a later design revision

When the designer changes colors, wording or layout without changing events or data paths, load the updated document and rerun the UI checks. When an event, path, unit or payload changes, update the integration and its tests as part of the same change. Keep a copy of the previous contract so you can see what changed.

For Envy's Godot and Unity editor workflows, `.envy.json` supports hot reload as documented. Check the behavior of the file type and environment you actually ship; a development-time reload is not proof of a release build update.

## Finish with a reviewable result

Ask the agent for the files changed, each event it connected, tests run and anything it could not verify. Review the code and play through the screen yourself. A successful handoff leaves both sides understandable: the designer can keep editing the UI, and the game code owns the rules behind it.

## Questions people ask

### Can the same UI design be used in Godot and Unity?

That depends on the format and runtimes. Envy documents can be loaded by its Godot and Unity runtimes, but engine-specific rendering and input behavior still need testing.

### What should an AI agent receive for UI integration?

Provide the UI document, event and data contract, reference renders, runtime instructions, project rules and a concrete acceptance checklist.

### Does generated controller code finish the game integration?

No. Generated controllers provide named starting points. The game still needs to supply real data, implement event handlers and test the resulting behavior.
