Unity Editor를 HTTP 브리지로 노출하고, scene, gameobject, sprite, ui, input, asset, material, package, tests, console, menu, editor, resource, events, workflow를 CLI만으로 제어할 수 있게 만드는 프로젝트입니다.
현재 기준은 "실제 Unity Editor에 붙어서 동작하는가" 입니다. mock serve와 tests/UnityCli.Tests는 CLI 프로토콜 회귀 확인용 보조 수단으로만 유지합니다.
src/UnityCli:.NET기반 CLI 본체unity-connector: Unity 패키지 형태의 Editor HTTP bridgesamples/workflows/smoke-test.json: 이벤트 기반 smoke workflowsamples/workflows/ui-touch-smoke.json: 2D/UI/touch/drag smoke workflowsamples/workflows/bootstrap.json: batch 호출 예시tests/UnityCli.Tests: mock bridge를 사용한 CLI 통합 테스트
직접 매핑되는 그룹 명령:
scene create|load|save|info|delete|unloadgameobject create|get|delete|duplicate|reparent|move|rotate|scale|set-transform|selectsprite createcomponent updatematerial create|assign|modify|infoasset list|add-to-scenepackage list|addtests list|runconsole get|clear|sendui canvas.create|button.create|toggle.create|slider.create|scrollrect.create|inputfield.create|text.create|image.createui toggle.set|slider.set|scrollrect.set|inputfield.set-text|focus|blurui click|double-click|long-press|drag|swipeinput tap|double-tap|long-press|drag|swipemenu executeeditor play|stop|pause|refresh|compile
브리지 레벨 명령:
statuscapabilitiestool listtool call <name> ...resource listresource get <name>events tailbatch run <file>workflow run <file>mock serve
dotnet test UnityCli.slnxmock bridge는 보조 검증용입니다. 실제 기능 확인은 아래 "실제 Editor 검증" 흐름을 기준으로 합니다.
반복적인 실기능 검증은 먼저 CLI를 빌드한 뒤, 실제 Unity Editor에 붙어서 scripts/verify-editor.sh를 실행하는 흐름을 기준으로 합니다.
dotnet run --project src/UnityCli -- mock serve
dotnet run --project src/UnityCli -- status
dotnet run --project src/UnityCli -- scene create path=Assets/Scenes/Main.unity
dotnet run --project src/UnityCli -- gameobject create name=Player primitive=Capsule position=[0,1,0]
dotnet run --project src/UnityCli -- workflow run samples/workflows/smoke-test.json벡터 인자는 셸 quoting 없이 position=1,2,3, rotation=0,90,0, scale=2,2,2 형태로 줄 수 있습니다.
기본 CLI 타임아웃은 10000ms 입니다. 테스트 실행이나 패키지 작업처럼 오래 걸릴 수 있는 명령은 --timeout-ms=60000 이상을 권장합니다.
unity-connector 폴더를 Unity 프로젝트의 Packages/com.geuneda.unity-cli-connector로 복사하거나 Git dependency로 추가합니다.
반복적인 로컬 개발/검증에는 Packages/com.geuneda.unity-cli-connector -> /path/to/unity-connector 형태의 embedded package 연결이 가장 안정적입니다.
이 방식으로 패키지 소스를 수정했다면 editor refresh 후 editor compile을 호출하는 흐름을 권장합니다.
editor play와 editor stop은 CLI에서 실제 상태가 전환될 때까지 기다린 뒤 반환합니다.
패키지가 로드되면 기본적으로 http://127.0.0.1:52737 에서 HTTP bridge를 열고, ~/.unity-cli/instances.json에 현재 엔드포인트를 기록합니다.
CLI는 --base-url이 없으면 이 instances.json의 default.baseUrl을 먼저 사용하고, 파일이 없을 때만 http://127.0.0.1:52737로 fallback 합니다.
현재 구현은 Editor API 중심이며, 아래 흐름을 지원합니다.
- 씬 생성/로드/저장/삭제
- GameObject 생성/조회/복제/삭제/변환/선택
- 2D sprite 생성
- Canvas/Button/Text/Image 생성
- Toggle/Slider/ScrollRect/InputField 생성 및 상태 변경
- 생성되는 UI 텍스트는
TextMeshProUGUI, 입력 필드는TMP_InputField기준 - EventSystem selection 기반 UI focus/blur 전환
- TMP Essential Resources가 없으면 첫 TMP UI 생성 시 자동 import
- 클릭/더블클릭/롱프레스/탭/드래그/스와이프 입력 디스패치
pointerId를 포함한 멀티포인터 입력 시뮬레이션- 컴포넌트 갱신
- 머티리얼 생성/할당/수정
- 에셋 목록 조회 및 프리팹 인스턴스화
- 패키지 목록 조회 및 설치 요청
- 테스트 목록 조회 및 EditMode/PlayMode 실행
- 콘솔 로그 발행/조회/초기화
- 메뉴 실행, Play/Pause/Refresh/Compile 제어
"/Applications/Unity/Hub/Editor/6000.3.11f1/Unity.app/Contents/MacOS/Unity" \
-projectPath "/Users/geuneda/Documents/GitHub/unity-cli/manual-test-project" \
-logFile "/Users/geuneda/Documents/GitHub/unity-cli/manual-test-project/Logs/unity-editor.log"
dotnet build src/UnityCli/UnityCli.csproj
scripts/verify-editor.sh
scripts/verify-editor.sh --stage ui-input --report reports/verify-editor/ui-input.jsonscripts/verify-editor.sh는 실제 Editor에 대해 아래 항목을 직렬 검증합니다.
status,tool list,resource listscene create|info|save|delete|unloadgameobject create|get|duplicate|reparent|move|rotate|scale|set-transform|select|deletesprite createcomponent updatematerial create|info|modify|assignasset list|add-to-scenepackage list|addconsole send|get|clearui canvas.create|button.create|toggle.create|slider.create|scrollrect.create|inputfield.create|text.create|image.createui toggle.set|slider.set|scrollrect.set|inputfield.set-text|focus|blurui click|double-click|long-press|drag|swipeinput tap|double-tap|long-press|drag|swipemenu executeresource get editor/state|scene/active|scene/hierarchy|ui/hierarchy|console/logs|tests/catalog|packages/listevents tailtests list|runworkflow run samples/workflows/smoke-test.jsonworkflow run samples/workflows/ui-touch-smoke.jsonbatch run samples/workflows/bootstrap.jsoneditor refresh|compile|play|pause|stop
스크립트 안에는 play mode 중 scene create가 실패해야 한다는 검증도 포함되어 있어서, 브리지 에러 메시지가 CLI에서 그대로 노출되는지까지 확인합니다.
기본 실행은 core, ui-input, tests, editor-lifecycle, resilience 다섯 stage를 모두 돌리고, --stage를 여러 번 주면 필요한 stage만 선택 실행할 수 있습니다.
실행 결과는 기본적으로 reports/verify-editor/latest.json에 JSON 리포트로 남습니다.
resilience stage는 compile/play/stop 전환 도중에도 status, resource get, events tail이 실제 Editor에서 계속 버티는지 확인합니다.
samples/workflows/smoke-test.json은 아래 패턴을 보여줍니다.
- 씬 생성
- Player 오브젝트 생성
- 로그 발행
console.log이벤트를 기다림- 테스트 실행
tests.completed이벤트를 기다림
이 구조로 "콜백이 오면 다음 스텝 실행" 형태의 CLI 기반 검증을 만들 수 있습니다.
현재 workflow run은 실행 시작 시점의 최신 이벤트 커서를 스냅샷하고, 각 tool 응답 안에 포함된 이벤트도 다음 waitFor에서 재사용합니다.
따라서 같은 workflow를 반복 실행해도 과거 실행의 console.log/tests.completed를 다시 잡지 않습니다.
samples/workflows/ui-touch-smoke.json은 매 실행마다 전용 씬을 새로 만들어서, 동일한 이름의 UI/GameObject가 누적돼도 안정적으로 반복 검증할 수 있게 해둔 상태입니다.
-
실제 Editor에서 확인됨:
scene.*gameobject.*sprite.creatematerial.*asset.list,asset.add-to-scenepackage.list,package.addtests.list,tests.run mode=EditMode,tests.run mode=PlayModeconsole.get,console.clear,console.sendui.canvas.create,ui.button.create,ui.toggle.create,ui.slider.create,ui.scrollrect.create,ui.inputfield.create,ui.text.create,ui.image.createui.toggle.set,ui.slider.set,ui.scrollrect.set,ui.inputfield.set-text,ui.focus,ui.blurui.click,ui.double-click,ui.long-press,ui.drag,ui.swipeinput.tap,input.double-tap,input.long-press,input.drag,input.swipemenu.executeeditor.refresh,editor.compile,editor.play,editor.pause,editor.stopresource list,resource get editor/state,resource get scene/hierarchy,resource get ui/hierarchy,resource get tests/catalog,resource get packages/listevents tailbatch run samples/workflows/bootstrap.jsonworkflow run samples/workflows/smoke-test.jsonworkflow run samples/workflows/ui-touch-smoke.jsonscripts/verify-editor.shend-to-end pass on Unity6000.3.11f1status.sessionId는 health 응답에 값이 비어 있어도 가장 최근bridge.started이벤트에서 복구
-
ui-inputstage에서 현재 실제 검증하는 UI 상태:- Button
double-click,long-press,swipe - Button
pointerIdclick - Sprite
double-tap,long-press,swipe - Sprite
pointerIddrag/swipe - Toggle 실제
ui.click토글 - Slider 실제
ui.drag값 변경 - Toggle
isOn변경 - Slider
value변경 - ScrollRect
normalizedPosition변경과 실제 drag 반응 - TMP_InputField 텍스트 입력과 EventSystem selection 기반 focus/blur 전환
- Button
-
입력 시뮬레이션 참고:
ui.click name=CliButton pointerId=21input.swipe worldFrom=2,1,0 worldTo=2.75,1,0 pointerId=9
-
현재 EditMode 제한:
- 입력 필드의
isFocused는 Unity EditMode에서ActivateInputField()이후에도 기대와 다르게 남을 수 있습니다. 현재 CLI 검증은eventSystemSelectedObjectName,isSelected, 그리고 probe 로그를 기준으로 포커스 전환을 확인합니다.
- 입력 필드의
-
실제 Editor 검증에 사용한 현재 manual test project 상태:
- embedded package:
Packages/com.geuneda.unity-cli-connector -> unity-connector - registry package:
[email protected] - sample prefab:
Assets/Prefabs/CliPrefab.prefab
- embedded package:
-
아직 제한이 남아 있음:
mock serve는 실기능 검증 경로가 아니라 CLI 회귀 테스트용입니다.
skill/ 디렉토리에 Claude Code용 스킬이 포함되어 있습니다. 이 스킬을 설치하면 Claude Code에서 unity-cli의 모든 명령을 자연어로 요청할 수 있습니다.
# 스킬 디렉토리를 Claude Code 스킬 경로에 복사
cp -r skill ~/.claude/skills/unity-cli또는 .claude/settings.json에 직접 추가:
{
"skills": [
"/path/to/unity-cli/skill"
]
}skill/SKILL.md-- 스킬 메타데이터 및 사용 가이드skill/references/commands.md-- 전체 명령 레퍼런스 (그룹별 인자, 예시 포함)