Building a Shared Foundation for AI-Assisted Unity Development
How a methodology-first approach — not just better prompting — enabled an AI agent to produce consistent, handoff-ready code for immersive installations across the team.
What this is
At Gensler's Digital Experience Design studio, we build large-scale interactive installations — LED walls, LiDAR person-tracking, CMS-driven content — under conditions that punish careless code: tight timelines, on-site hardware, and displays large enough that any dropped frame is immediately visible to a room full of people.
We were already using AI coding agents. The problem was what they produced without guidance: a different fade pattern, a different event structure, a different file layout on every project. Technically functional. Architecturally incoherent. Nothing was reusable, and no developer joining mid-project could trust the agent's choices without reverse-engineering them first.
This project is the fix. Not a new app — a foundation that makes the agent behave like a disciplined team member instead of a capable stranger.
The goal: any AI coding agent (Copilot, Claude, Cursor) onboarded to this repo produces code that is consistent with our patterns, reuses our existing scripts, and is ready to hand off — whether the next person who touches it is a developer or the agent itself on a future project.
What I looked at first
What I actually looked at first
Before writing a single line, I did an audit of our previous Unity projects. Not to document them — to find the commonalities: what every project re-solves from scratch, what breaks when it's rebuilt instead of reused, and where technical debt compounds fastest in an installation context.
The pattern was the same every time. Five or six categories of scripts — transitions, asset loaders, CMS parsers, sensor pipelines, networking — written differently on every project because whoever wrote them (human or agent) had no shared frame of reference. The logic was equivalent. The interfaces were not.
That's the core insight this repo is built on: the problem isn't skill, it's the absence of a shared vocabulary. Give an agent that vocabulary and it converges on consistent output. Leave it without and it improvises, every time.
The PRD approach
How I prepared the agent to run longer
Most people use AI by chatting — iterating in real time, correcting the output, steering the agent through each step. That works for one-off tasks. It doesn't scale to building a consistent system across a team and multiple projects.
The approach here was different: write the agent's context before it touches any code. The same way you brief a new developer on their first day — not by watching them work and correcting every line, but by giving them enough grounding to make good decisions on their own.
That meant starting with a Product Requirements Document that forced me to answer, up front, questions the agent would otherwise have to guess at.
PRD — unity-agentic-development
──────────────────────────────────────────
PROBLEM
• Every DXD Unity project reinvents the same ~6 script categories
• AI agents produce inconsistent code without shared context
• No handoff path: a developer joining mid-project must reverse-engineer agent choices
GOALS (success criteria)
• Agent produces pattern-matched code on first generation, not after correction
• Toolkit grows from real project scripts, not invented ones
• Designer can adjust animation timing and state behavior without developer help
• Tool-agnostic: switching agent tools requires a pointer file, not a rewrite
AGENT vs. HUMAN RESPONSIBILITIES
Agent owns: script structure, serialized fields, coroutine logic,
CMS parsers, toolkit contributions
Human owns: Inspector wiring, on-site calibration,
experiential decisions, toolkit review/approval
ARCHITECTURAL INVARIANTS (non-negotiable)
• Inspector-first: every configurable value is a [SerializeField]
• Self-contained scripts: one file, one responsibility, no shared static state
• No FindObjectOfType, no SendMessage, no editor-only functions
• Network addresses are serialized fields, never hardcoded
TOOLKIT CONTRIBUTION LOOP
Project generates reusable script
→ agent strips project-specific logic
→ agent verifies pattern compliance
→ developer reviews
→ lands in toolkit
This is how the toolkit grows: from real installations, not speculation.
The PRD became AGENTS.md — the single file every agent reads before writing anything. All tool-specific entry points (CLAUDE.md, .cursorrules, Copilot instructions) are thin pointers to it. Switching agent tools is a one-file change. The guidance never diverges.
The decision ladder
The core behavioral rule I gave the agent is a decision ladder it runs every time before writing a script. A new script that ignores an existing toolkit script is a defect, even if it works. Consistency is the product
1. Does a toolkit script already do this?
→ Copy it, adapt the copy. Done.
2. Does a toolkit script almost do this?
→ Copy it, rename it with a project prefix, modify the copy.
Note the gap as a possible future contribution. Done.
3. Does a documented pattern cover this?
→ Follow the pattern exactly (fade controller, asset loader,
mode manager, CMS parser, LiDAR pipeline).
4. Only then, write new.
→ Confirm single responsibility and Inspector API first.
Why this matters for designers: because scripts follow the same Enter()/Exit() lifecycle and expose everything through Inspector fields, a designer can open a Unity project and change the speed of an animation, adjust a transition curve, or toggle behavior at state entry without touching code. That was a deliberate design goal — lowering the technical barrier to the software.
What's in the toolkit
What's in the toolkit
The scripts in toolkit/Runtime/ are distilled from real installation projects, stripped of project-specific logic, and verified against the patterns. They cover the categories that every DXD project hits:
Transitions — Fade controllers for RawImage, Image, Text, Materials; animators for scale, FOV, skybox; sequencers for timed events and text playback
Asset Loading — Runtime loaders for images and video with OnReady events for load-then-reveal patterns
Sensing — Full LiDAR person-tracking pipeline: WebSocket receiver → zone detection → wall-space mapping
Networking — WebSocket inspector, UDP heartbeat sender
CMS — Annotated templates for per-mode databases and parsers
Core / Utilities — Audio playback, keyboard bindings, cursor handling, FPS display, screenshot capture, text pagination
Before / after
What changes in practice
The examples/ folder in the repo holds before/after comparisons of the same script written without toolkit guidance versus with it. The functional outcome is identical. The structural difference is significant.
Without toolkit guidance:
• Hardcoded durations inside coroutine logic
• Different naming conventions per script
• FindObjectOfType for dependencies
• No Inspector button to test manually
• No OnReady event for downstream wiring
With toolkit guidance:
• [SerializeField] float fadeDuration
• [SerializeField] AnimationCurve fadeCurve
• All references via serialized fields
• FadeIn() / FadeOut() public API
• Inspector button to trigger in-editor
• UnityEvent OnReady for wiring in Inspector
The second version looks the same whether it was written by a developer, a different developer, or the agent itself on a future project. That's the goal.
How it grows
The repo is designed to improve with every project. The contribution loop is explicit — the agent is expected to participate in it, not just consume the toolkit:
• When a project resolves a non-obvious issue, the agent proposes a lesson entry for the shared memory file
• When a project script is generic and pattern-compliant, the agent flags it as a toolkit contribution candidate
• When documentation drifts from actual code, the agent reports it
The repo is versioned as a whole, with a changelog, so a project can record which toolkit version it was built against — important because installations are revisited years later.
The strategic intent: over time, the toolkit accumulates the studio's proven solutions. The agent gets better context. New projects build faster. Developers joining the studio onboard faster. The investment compounds.
What I want you to take away
This project is evidence of a specific kind of technical leadership: identifying where a team is losing leverage, designing a system to recover it, and building the infrastructure that makes the right behavior automatic.
Using AI well in an engineering context isn't about prompting skill. It's about preparation: understanding the system you're building, encoding its patterns explicitly, and setting the agent up to extend those patterns rather than diverge from them. The result isn't just faster code generation — it's code the team can trust, build on, and hand off.
The same methodology applies to any stack. This is the first implementation. The structure is designed to be replicated as sibling repos for TypeScript, Three.js, and whatever else the studio adopts.