Fixed weird behaviour with drop down menus and crash

This commit is contained in:
Antoine Pilote
2023-08-02 18:47:30 -04:00
parent 4552b0ee69
commit 7543d5aca4
2 changed files with 16 additions and 3 deletions

View File

@@ -245,11 +245,15 @@ namespace Nuake {
}
}
m_IsViewportFocused = ImGui::IsWindowFocused();
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing())
if (m_IsHoveringViewport && !m_IsViewportFocused && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_2))
{
ImGui::FocusWindow(ImGui::GetCurrentWindow());
}
m_IsViewportFocused = ImGui::IsWindowFocused();
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing())
{
const auto windowPosNuake = Vector2(windowPos.x, windowPos.y);
auto& gbuffer = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer();
auto pixelPos = Input::GetMousePosition() - windowPosNuake;
@@ -259,7 +263,11 @@ namespace Nuake {
if (const int result = gbuffer.ReadPixel(3, pixelPos); result > 0)
{
Selection = EditorSelection(Entity{ (entt::entity)(result - 1), Engine::GetCurrentScene().get()});
auto& ent = Entity{ (entt::entity)(result - 1), Engine::GetCurrentScene().get() };
if (ent.IsValid())
{
Selection = EditorSelection(ent);
}
}
else
{