SceneWindow
클래스 구조 정리SceneWindow
는 에디터 내에서 씬(Scene)을 시각적으로 편집할 수 있는 뷰포트입니다.
EditorCamera
를 이용해 별도의 렌더 타겟에 씬을 렌더링하고,
해당 이미지를 ImGui 위에 출력합니다.
멤버 | 설명 |
---|---|
mEditorCameraObject |
씬뷰 전용 카메라가 부착된 GameObject |
mEditorCamera |
실제 렌더링을 담당하는 EditorCamera 컴포넌트 |
GuizmoType |
현재 활성화된 변환 Gizmo (이동, 회전, 스케일) |
ViewportBounds[2] |
뷰포트의 좌상단, 우하단 ImGui 위치 |
ViewportSize |
ImGui 내 SceneView의 크기 |
ViewportFocused / Hovered |
현재 마우스 포커스 여부 (입력 판단용) |
함수 | 설명 |
---|---|
Initialize() |
에디터 카메라 객체 생성, 렌더타겟 초기화 |
Run() |
카메라 업데이트, 씬 렌더링, Gizmo 출력, ImGui 이미지 출력 |
OnGUI() |
SceneView 내 추가적인 UI 편집 요소 (없으면 생략 가능) |
SetGuizmoType() |
Gizmo 조작 모드 설정 |
cpp
복사편집
ImGui::Begin("Game");
ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail();
ViewportSize = Vector2{ viewportPanelSize.x, viewportPanelSize.y };
ya::graphics::Texture* texture = FrameBuffer->GetAttachmentTexture(0);
ImGui::Image((ImTextureID)texture->GetSRV().Get(), ImVec2{ ViewportSize.x, ViewportSize.y });
if (ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("PROJECT_ITEM")) {
const auto path = static_cast<const wchar_t*>(payload->Data);
OpenScene(path);
}
ImGui::EndDragDropTarget();
}
for (auto& iter : EditorWindows)
iter.second->Run();
ImGui::End();
단계 | 설명 |
---|---|
ImGui::Begin("Game") |
GameView 창 시작 |
GetContentRegionAvail() |
ImGui 내부에서 사용 가능한 영역 크기 (픽셀) 계산 |
FrameBuffer->GetAttachmentTexture(0) |
게임 카메라가 렌더링한 이미지(Texture) 가져오기 |
ImGui::Image(...) |
해당 Texture를 GameView에 출력 |
ImGui::BeginDragDropTarget() |
드래그 앤 드롭 지원 (예: 프로젝트 창에서 씬 드래그) |
EditorWindows 루프 |
에디터 내 다른 창들(Inspector, Hierarchy 등)도 실행 |
ImGui::End() |
GameView 창 종료 |