Fix ImGui rendering in-Editor
-Ensure ViewportContext rendertick notifications always fire -Use viewport size to determine ImGui resolution, ensure OnViewportSizeChanged is always up-to-date for the default viewport context
This commit is contained in:
@@ -58,6 +58,15 @@ namespace AZ
|
||||
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
|
||||
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
|
||||
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiManagerListenerBus::Broadcast(&ImGui::IImGuiManagerListener::SetResolutionMode, ImGui::ImGuiResolutionMode::LockToResolution);
|
||||
auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext();
|
||||
if (defaultViewportContext)
|
||||
{
|
||||
OnViewportSizeChanged(defaultViewportContext->GetViewportSize());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImguiAtomSystemComponent::Deactivate()
|
||||
@@ -75,6 +84,13 @@ namespace AZ
|
||||
{
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiManagerListenerBus::Broadcast(&ImGui::IImGuiManagerListener::Render);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImguiAtomSystemComponent::OnViewportSizeChanged(AzFramework::WindowSize size)
|
||||
{
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiManagerListenerBus::Broadcast(&ImGui::IImGuiManagerListener::SetImGuiRenderResolution, ImVec2{aznumeric_cast<float>(size.m_width), aznumeric_cast<float>(size.m_height)});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user