Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions Source/ImGui/Private/ImGuiModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ TSharedPtr<FImGuiContext> FImGuiModule::FindOrCreateSessionContext(const int32 P
Port += PieSessionId + 1;
}

#if WITH_ENGINE
const FWorldContext* WorldContext = GEngine->GetWorldContextFromPIEInstance(PIEInstance);
UGameViewportClient* GameViewport = WorldContext ? WorldContext->GameViewport : GEngine->GameViewport;
if (IsValid(GameViewport))
{
Context = CreateViewportContext(GameViewport);
}
#if WITH_EDITOR
if (GIsEditor && PieSessionId == INDEX_NONE)
else if (GIsEditor)
{
const IMainFrameModule* MainFrameModule = FModuleManager::GetModulePtr<IMainFrameModule>("MainFrame");
const TSharedPtr<SWindow> MainFrameWindow = MainFrameModule ? MainFrameModule->GetParentWindow() : nullptr;
Expand All @@ -72,21 +79,12 @@ TSharedPtr<FImGuiContext> FImGuiModule::FindOrCreateSessionContext(const int32 P
Context = CreateWindowContext(MainFrameWindow.ToSharedRef());
}
}
else
#endif
{
#if WITH_ENGINE
const FWorldContext* WorldContext = GEngine->GetWorldContextFromPIEInstance(PieSessionId);
UGameViewportClient* GameViewport = WorldContext ? WorldContext->GameViewport : GEngine->GameViewport;
if (IsValid(GameViewport))
{
Context = CreateViewportContext(GameViewport);
}
else
{
Context = FImGuiContext::Create();
}
#endif

if (!Context.IsValid())
{
Context = FImGuiContext::Create();
}

if (Context.IsValid())
Expand Down