From 6a939b0fa475ae64cec4ab546321846b641cb303 Mon Sep 17 00:00:00 2001 From: VTui22 Date: Thu, 2 Nov 2023 17:49:48 +0800 Subject: [PATCH] fix editor panel --- Engine/Source/Editor/UILayers/SceneView.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Engine/Source/Editor/UILayers/SceneView.cpp b/Engine/Source/Editor/UILayers/SceneView.cpp index 49120ac6..85c4138f 100644 --- a/Engine/Source/Editor/UILayers/SceneView.cpp +++ b/Engine/Source/Editor/UILayers/SceneView.cpp @@ -330,13 +330,21 @@ void SceneView::Update() ImVec2 windowPos = ImGui::GetWindowPos(); ImVec2 mousePos = ImGui::GetMousePos(); + bool isMouseInsideSeneView = false; cd::Vec2f rightDown(windowPos.x + regionSize.x, windowPos.y + regionSize.y); // Check if mouse hover on the area of SceneView so it can control. ImVec2 cursorPosition = ImGui::GetCursorPos(); ImVec2 sceneViewPosition = ImGui::GetWindowPos() + cursorPosition; SetWindowPos(sceneViewPosition.x, sceneViewPosition.y); - + if (ImGui::IsWindowHovered()) + { + isMouseInsideSeneView = true; + } + else + { + isMouseInsideSeneView = false; + } // Draw scene. ImGui::Image(reinterpret_cast(m_pRenderTarget->GetTextureHandle(0).idx), ImVec2(m_pRenderTarget->GetWidth(), m_pRenderTarget->GetHeight())); @@ -372,7 +380,7 @@ void SceneView::Update() } m_isMouseDownFirstTime = false; - if (mousePos.x > windowPos.x && mousePos.x < rightDown.x() && mousePos.y > windowPos.y && mousePos.y < rightDown.y() && !m_isTerrainEditMode) + if (isMouseInsideSeneView && !m_isTerrainEditMode) { m_pCameraController->SetIsInViewScene(true); m_isMouseShow = false;