원클릭으로
viewbuilder-extract
MonoBehaviour에서 UI 생성 코드를 ViewBuilder 정적 클래스 + Refs struct로 분리
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
MonoBehaviour에서 UI 생성 코드를 ViewBuilder 정적 클래스 + Refs struct로 분리
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Unity Play 시작 씬, scene-authored UI source-of-truth, authored-first binder, RobotControl/Onboarding 라우팅 착시를 함께 디버깅하는 운영 스킬
Use when adding, extending, or debugging Waypoint Teaching & Playback: saving robot poses as waypoints, sequencing them, playing/looping sequences, exporting/importing JSON, coroutine-based runner engine, or teaching UI integration.
Robot Library / Sandbox robot showroom 디버깅과 튜닝 — showroomoutput, comparestrip, preview pod, Game view vs Scene view 스케일 차이, hero/page selection, runtime root 중복
Use when working on FAIRINO FR5 6-axis robot integration in this repo: collecting official FR5 docs, mapping Unity UI inputs to the FAIRINO C# SDK, planning real-robot control and safety, documenting FR5 hardware/DH/protocol details, or building adapters around MoveJ/MoveL/ServoJ/ServoCart and status feedback.
Main 탭형 학습 쉘의 로봇별 JSON 콘텐츠를 추가/수정/검증하는 스킬. `Assets/Runtime/Resources/LearningTabs/*.json` 문안 업데이트, 새 로봇용 탭 문서 추가, MainLearningTabsLoader fallback 조정, Main 탭 콘텐츠 schema 변경, JSON 파싱/폴백/Unity MCP 검증이 필요할 때 사용한다.
씬별/모드별 UI 가시성 제어 — scene, panel visibility, overlap, mode isolation, 배타 그룹
| name | viewbuilder-extract |
| description | MonoBehaviour에서 UI 생성 코드를 ViewBuilder 정적 클래스 + Refs struct로 분리 |
기존 MonoBehaviour에서 UI 생성 코드가 비대할 때 (100줄+), 또는 새 씬/패널의 UI 구조를 코드로 빌드할 때.
키워드: ViewBuilder, UI 분리, 패널 추출, Refs struct, UI 생성 코드 정리
OnboardingManager.cs)EnsurePresentation() / EnsureLayout() / BuildUI() 내 UI 생성 코드Assets/Scripts/UI/CLAUDE.md — UI 폴더 규칙docs/ref/code-patterns.md — §8-9 코딩 패턴 (인코딩, 헤더, 네이밍, 수명주기)Assets/Scripts/UI/OnboardingViewBuilder.cs — 단일 화면 (Refs struct + static Build)Assets/Scripts/UI/HomeContinueHubViewBuilder.cs — 복합 카드Assets/Scripts/UI/SandboxActionPanelViewBuilder.cs — 버튼 그룹Assets/Scripts/UI/SnapshotLitePanelViewBuilder.cs — 상태 텍스트 + 버튼 (Refs 패턴)Assets/Scripts/UI/UIComponentFactory.cs — 사용 가능한 위젯 빌더 목록Assets/Scripts/UI/UIDesignTokens.cs — 색상/크기/간격 토큰MonoBehaviour가 빌드 후 참조해야 하는 UI 요소를 readonly struct로 정의합니다.
// Folder: UI - HUD/view components only; no kinematics logic.
namespace KineTutor3D.UI
{
/// <summary>
/// {PanelName} UI 참조를 보관하는 불변 구조체입니다.
/// </summary>
internal readonly struct {PanelName}ViewRefs
{
public {PanelName}ViewRefs(RectTransform root, Text titleText, Button actionButton)
{
Root = root;
TitleText = titleText;
ActionButton = actionButton;
}
public RectTransform Root { get; }
public Text TitleText { get; }
public Button ActionButton { get; }
}
}
규칙:
HeadlineText, SkipButton)readonly struct + getter-only properties// Folder: UI - HUD/view components only; no kinematics logic.
using UnityEngine;
using UnityEngine.UI;
namespace KineTutor3D.UI
{
/// <summary>
/// {PanelName} UI 계층을 코드로 빌드합니다.
/// </summary>
internal static class {PanelName}ViewBuilder
{
public static {PanelName}ViewRefs Build(Transform canvasRoot, Font fallbackFont)
{
// UIComponentFactory + UIDesignTokens 사용
var root = UIComponentFactory.CreatePanel(canvasRoot, "{PanelName}Root",
UIDesignTokens.Colors.SurfaceOverlay);
var title = UIComponentFactory.CreateText(root.transform, "Title",
TypographyPreset.HeadingSm, UIDesignTokens.Colors.TextPrimary,
"제목", fallbackFont);
var btn = UIComponentFactory.CreatePrimaryButton(root.transform, "ActionBtn",
"확인", fallbackFont);
return new {PanelName}ViewRefs(root, title, btn.GetComponentInChildren<Text>());
}
}
}
규칙:
internal static class — 인스턴스 불필요{PanelName}ViewRefsUIComponentFactory.Create*() 사용 필수UIDesignTokens.Colors.*UIDesignTokens.Type.* / UIDesignTokens.Space.*new Color() 리터럴 금지원본 MonoBehaviour에서:
EnsurePresentation()에서 ViewBuilder.Build() 호출// MonoBehaviour 패턴
{PanelName}ViewRefs refs;
void EnsurePresentation()
{
if (refs.Root != null) return;
var canvas = GetComponentInParent<Canvas>()?.transform ?? transform;
refs = {PanelName}ViewBuilder.Build(canvas, fallbackFont);
}
void BindListeners()
{
if (listenersBound) return;
listenersBound = true;
refs.ActionButton?.onClick.AddListener(OnAction);
}
void UnbindListeners()
{
if (!listenersBound) return;
listenersBound = false;
refs.ActionButton?.onClick.RemoveListener(OnAction);
}
{PanelName}ViewBuilder.cs (같은 UI/ 폴더){PanelName}ViewRefs.cs 분리EF BB BF) 필수// Folder: UI - HUD/view components only; no kinematics logic.Transform/Font 등 순수 데이터만 전달SetActive 호출 금지 — 가시성 제어는 외부 책임static 필드/상태 보관 금지 — 순수 빌드 함수만UiRuntimeStyle 신규 사용 금지 — UIComponentFactory 사용 (기존 ViewBuilder 유지보수 시에만 허용)MonoBehaviour / Component 직접 저장 금지 — UI 요소(RectTransform, Text, Button 등)만internal static classinternal readonly structnew Color() 리터럴 0개UIComponentFactory.Create* 사용EnsurePresentation()에서 null 체크 후 Build 호출BindListeners() / UnbindListeners() 분리[viewbuilder-extract 적용]
- 원본: {MonoBehaviour 파일명} ({원본 줄 수}줄)
- 추출: {ViewBuilder 파일명} ({추출 줄 수}줄)
- 원본 축소: {원본 줄 수} → {새 줄 수}줄 ({감소 비율}%)
- Refs 필드: {필드 목록}
- UIComponentFactory 호출: {개수}건
- Unity 컴파일: 에러 0
ui-design-system — 토큰/컴포넌트 팩토리 사용scene-ui-visibility — SetVisible 패턴 연동