Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support PIE server processes #12

Open
wants to merge 1 commit into
base: Main
Choose a base branch
from
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 @@ -54,8 +54,15 @@ TSharedPtr<FImGuiContext> FImGuiModule::FindOrCreateSessionContext(const int32 P
Port += PIEInstance + 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 && PIEInstance == INDEX_NONE)
else if (GIsEditor)
{
const IMainFrameModule* MainFrameModule = FModuleManager::GetModulePtr<IMainFrameModule>("MainFrame");
const TSharedPtr<SWindow> MainFrameWindow = MainFrameModule ? MainFrameModule->GetParentWindow() : nullptr;
Expand All @@ -64,21 +71,12 @@ TSharedPtr<FImGuiContext> FImGuiModule::FindOrCreateSessionContext(const int32 P
Context = CreateWindowContext(MainFrameWindow.ToSharedRef());
}
}
else
#endif
{
#if WITH_ENGINE
const FWorldContext* WorldContext = GEngine->GetWorldContextFromPIEInstance(PIEInstance);
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