- Change code blocks from PowerShell to Bash for macOS examples across all adapters. - Add macOS-specific instructions for running context scripts in the documentation of each adapter. - Update session file paths to reflect user-scoped locations for both Windows and macOS. - Enhance overall clarity and consistency in the documentation for better user experience.
3.9 KiB
Unity Notes
Bridge:
python adapters/unity_adapter/unity_bridge.py --stdin
Runtime: Unity Editor package -> tokenized localhost command endpoint ->
UnityEditor / UnityEngine C# code on the Editor main thread.
Context:
Windows:
Get-Content adapters/unity_adapter/examples/context.json -Raw | python adapters/unity_adapter/unity_bridge.py --stdin
macOS:
cat adapters/unity_adapter/examples/context.json | python adapters/unity_adapter/unity_bridge.py --stdin
Local Memory
If APP.local.md exists in this directory, review it before performing an
operation when local installation details, prior failures, or version-specific
behavior may matter.
After completing an operation, if you encountered a repeatable issue or
verified something worth remembering about this local installation, add a short
note to APP.local.md.
Keep notes concise and factual. Record only local, reusable insights such as
verified quirks, recovery steps, version-specific gaps, or runtime-discovered
details. Do not copy general guidance from APP.md, and do not add temporary
task-specific notes.
API lookup workflow:
- Use
docs/api-index.txtas the primary operation index. - Workflow for every task:
- Understand the user's intent.
- Search (
rg)docs/api-index.txtfor matching operations. - If needed, introspect the live app/runtime to resolve ambiguity.
- If still needed, search official documentation online.
- Avoid over-relying on training, as it's fragile and can break. Do not directly read the index file, which can be heavy.
Connection recovery:
If the bridge says the session file is missing or the local eval endpoint is unreachable, ask the user to open a Unity project that has the Creative Adapter Bridge package installed. If the package is not installed, install it into the target Unity project:
powershell -ExecutionPolicy Bypass -File adapters/unity_adapter/install_package.ps1 -ProjectPath "C:\Path\To\UnityProject"
Unity-specific notes:
- Unity Editor scripting is C#, but Unity does not expose an arbitrary C#
string
evalAPI. This adapter accepts command JSON for tested Editor actions. - For deeper project-specific behavior, add explicit actions to the package or create project-local Editor scripts. Do not pretend arbitrary C# was executed.
- The package generates a random token on Editor startup and writes it with the
eval URL to a user-scoped session file:
%APPDATA%\creative-adapters\unity.jsonon Windows or~/creative-adapters/unity.jsonon macOS. The Python bridge reads this file automatically and sendsX-Bridge-Token. - Commands run on Unity's main Editor thread.
- Do not enter/exit Play Mode, save scenes, build, import large assets, edit project settings, or change scenes unless explicitly asked.
- Prefer undo-backed commands. The included create/transform/component actions
use Unity's
UndoAPI where applicable. - For visually judged scene or Game view changes, prefer the temporary
preview-verification workflow in
shared/coexistence.mdinstead of assuming the visible result. - Grep-friendly API index:
docs/api-index.txt(records are prefixed withCLASS,CONSTRUCTOR,METHOD,PROPERTY).
Supported command actions:
createPrimitive: creates a Unity primitive.primitiveTypeuses Unity'sPrimitiveTypenames, includingCube,Sphere,Capsule,Cylinder,Plane, andQuad. Optional fields includename, position fields (x,y,z), scale fields (scaleX,scaleY,scaleZ),color, andundoLabel.setTransform: changes the target object's position and/or scale. Targets resolve bypath, thenname, then the active selected GameObject. UsesetPositionandsetScaleto choose which values apply.executeMenuItem: runs a Unity menu item by path, such asGameObject/Light/Directional Light.addComponent: adds a component to the target GameObject bycomponentType.