Skip to content

Instantly share code, notes, and snippets.

@gamerxl
Last active January 15, 2023 17:29
Show Gist options
  • Save gamerxl/20e943b2de4d09ecb0de72f66967857d to your computer and use it in GitHub Desktop.
Save gamerxl/20e943b2de4d09ecb0de72f66967857d to your computer and use it in GitHub Desktop.
Re-enable settings ServerMapNameOverride from advanced play settings for dedicated servers in play in editor (PIE) mode from c++ in unreal engine. It reuses the existing editor user setting ServerMapNameOverride from advanced settings for play mode and play settings in editor.
// Add module "UnrealEd" to the PublicDependencyModuleNames in your module build rules.
// Example how to override map for dedicated servers in play in editor (PIE) mode and reuse the mentioned setting.
// Use a custom game instance and override method InitializeForPlayInEditor from UGameInstance.
FGameInstancePIEResult UDefaultGameInstance::InitializeForPlayInEditor(
int32 PIEInstanceIndex,
const FGameInstancePIEParameters& Params)
{
FGameInstancePIEParameters NewParams = Params;
// Re-enable editor user setting ServerMapNameOverride from advanced settings
// for play mode and play settings in editor.
if (Params.bRunAsDedicated)
{
FString ServerMapNameOverride;
Params.EditorPlaySettings->GetServerMapNameOverride(ServerMapNameOverride);
NewParams.OverrideMapURL = ServerMapNameOverride;
}
return Super::InitializeForPlayInEditor(PIEInstanceIndex, NewParams);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment