Fixed duplicated registrations of ImGui Demo that were introduced in recent changes.

This commit is contained in:
Sebastian 2018-11-27 20:56:02 +00:00
parent e05cea2789
commit c662869820
2 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,9 @@ FImGuiModuleManager::FImGuiModuleManager()
: ModuleCommands(*this)
, ImGuiDemo(*this)
{
// Register in context manager to get information whenever a new context proxy is created.
ContextManager.OnContextProxyCreated().AddRaw(this, &FImGuiModuleManager::OnContextProxyCreated);
// Typically we will use viewport created events to add widget to new game viewports.
ViewportCreatedHandle = UGameViewportClient::OnViewportCreated().AddRaw(this, &FImGuiModuleManager::OnViewportCreated);
@ -169,7 +172,6 @@ void FImGuiModuleManager::AddWidgetToViewport(UGameViewportClient* GameViewport)
// Make sure that we have a context for this viewport's world and get its index.
int32 ContextIndex;
auto& ContextProxy = ContextManager.GetWorldContextProxy(*GameViewport->GetWorld(), ContextIndex);
ContextProxy.OnDraw().AddLambda([this, ContextIndex]() { ImGuiDemo.DrawControls(ContextIndex); });
// Make sure that textures are loaded before the first Slate widget is created.
LoadTextures();
@ -208,3 +210,8 @@ void FImGuiModuleManager::AddWidgetsToActiveViewports()
}
}
}
void FImGuiModuleManager::OnContextProxyCreated(int32 ContextIndex, FImGuiContextProxy& ContextProxy)
{
ContextProxy.OnDraw().AddLambda([this, ContextIndex]() { ImGuiDemo.DrawControls(ContextIndex); });
}

View File

@ -59,6 +59,8 @@ private:
void AddWidgetToViewport(UGameViewportClient* GameViewport);
void AddWidgetsToActiveViewports();
void OnContextProxyCreated(int32 ContextIndex, FImGuiContextProxy& ContextProxy);
// Event that we call after ImGui is updated.
FSimpleMulticastDelegate PostImGuiUpdateEvent;