Last active
January 15, 2023 17:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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