CenterNewWindow

CenterNewWindow

#Overview

name: CenterNewWindow

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CenterNewWindow is to control the positioning of new Play-In-Editor (PIE) windows in Unreal Engine 5. It is part of the editor’s play settings configuration.

This setting variable is primarily used by the Unreal Engine’s editor subsystem, specifically in the Play-In-Editor functionality. It is referenced in the UnrealEd module, which is responsible for the editor’s core functionality.

The value of this variable is set in the ULevelEditorPlaySettings class, which is a configuration class for editor play settings. It is initialized to false by default in the constructor of ULevelEditorPlaySettings.

CenterNewWindow interacts with other variables such as NewWindowPosition, NewWindowWidth, and NewWindowHeight. When CenterNewWindow is true, it takes precedence over NewWindowPosition.

Developers should be aware that:

  1. When CenterNewWindow is true, the PIE window will be centered on the screen, regardless of the NewWindowPosition value.
  2. When it’s false, the PIE window will use the NewWindowPosition value if it’s not set to FIntPoint::NoneValue.
  3. This setting affects the behavior of multiple PIE instances, influencing how additional windows are positioned.

Best practices when using this variable include:

  1. Consider the user’s preference for window positioning. Some users may prefer centered windows, while others may want more control over window placement.
  2. Be mindful of multi-monitor setups. Centering might not always be ideal in these scenarios.
  3. Use in conjunction with NewWindowPosition for more granular control over window placement when centering is not desired.
  4. Remember that this setting affects the initial position of the PIE window. Users can still move the window after it’s created.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:226, section: [/Script/UnrealEd.LevelEditorPlaySettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/MovieSceneCaptureDialog/Private/MovieSceneCaptureDialogModule.cpp:480

Scope (from outer to inner):

file
function     void FInEditorCapture::OverridePlaySettings

Source code excerpt:

	PlayInEditorSettings->NewWindowWidth = Settings.Resolution.ResX;
	PlayInEditorSettings->NewWindowHeight = Settings.Resolution.ResY;
	PlayInEditorSettings->CenterNewWindow = false;
	PlayInEditorSettings->NewWindowPosition = FIntPoint::NoneValue; // It will center PIE to the middle of the screen the first time it is run (until the user drag the window somewhere else)
	PlayInEditorSettings->LastExecutedPlayModeType = EPlayModeType::PlayMode_InEditorFloating;

	// Reset everything else
	PlayInEditorSettings->GameGetsMouseControl = false;
	PlayInEditorSettings->ShowMouseControlLabel = false;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorPlaySettings.h:305

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject

Source code excerpt:

	/** Whether the new window should be centered on the screen. */
	UPROPERTY(config, EditAnywhere, Category = GameViewportSettings)
	uint32 CenterNewWindow:1;

public:

	/** Whether to always have the PIE window on top of the parent windows. */
	UPROPERTY(config, EditAnywhere, Category = PlayInNewWindow, meta = (ToolTip="Always have the PIE window on top of the parent windows."))
	uint32 PIEAlwaysOnTop:1;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp:616

Scope (from outer to inner):

file
function     void UEditorEngine::EndPlayMap

Source code excerpt:


				// Only update it if "Always center window to screen" is disabled, and the size was not 0 (which means it is attached to the editor rather than being an standalone window)
				if (!PlaySettingsConfig->CenterNewWindow && PlaySettingsConfig->LastSize.X > 0 && PlaySettingsConfig->LastSize.Y > 0)
				{
					PlaySettingsConfig->NewWindowPosition = PlaySettingsConfig->MultipleInstancePositions[WindowIndex];
					PlaySettingsConfig->NewWindowWidth = PlaySettingsConfig->LastSize.X;
					PlaySettingsConfig->NewWindowHeight = PlaySettingsConfig->LastSize.Y;
				}
			}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp:3599

Scope (from outer to inner):

file
function     void UEditorEngine::GetWindowSizeAndPositionForInstanceIndex

Source code excerpt:

	if (InWorldContext.bIsPrimaryPIEInstance)
	{
		// Center window if CenterNewWindow checked or if NewWindowPosition is FIntPoint::NoneValue (-1,-1)
		if (InEditorPlaySettings.CenterNewWindow || InEditorPlaySettings.NewWindowPosition == FIntPoint::NoneValue)
		{
			// We don't store the last window position in this case, because we want additional windows
			// to open starting at the top left of the monitor.
			OutPosition.X = FMath::RoundToInt((DisplaySize.X / 2.f) - (OutSize.X / 2));
			OutPosition.Y = FMath::RoundToInt((DisplaySize.Y / 2.f) - (OutSize.Y / 2));
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevelNewProcess.cpp:266

Scope (from outer to inner):

file
function     void UEditorEngine::LaunchNewProcess

Source code excerpt:


		// If not center window nor NewWindowPosition is FIntPoint::NoneValue (-1,-1)
		if (!InParams.EditorPlaySettings->CenterNewWindow && InParams.EditorPlaySettings->NewWindowPosition != FIntPoint::NoneValue)
		{
			FIntPoint WindowPosition = InParams.EditorPlaySettings->NewWindowPosition;
			
			WindowPosition.X += FMath::Max(InInstanceNum - 1, 0) * WindowSize.X;
			WindowPosition.Y += static_cast<int32>(SWindowDefs::DefaultTitleBarSize * FPlatformApplicationMisc::GetDPIScaleFactorAtPoint(0, 0));

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/LevelEditorPlaySettingsCustomization.cpp:102

Scope (from outer to inner):

file
function     bool SScreenPositionCustomization::HandleNewWindowPositionPropertyIsEnabled

Source code excerpt:

bool SScreenPositionCustomization::HandleNewWindowPositionPropertyIsEnabled() const
{
	bool CenterNewWindow;
	CenterWindowProperty->GetValue( CenterNewWindow );
	return !CenterNewWindow;
}

void SScreenResolutionCustomization::Construct( const FArguments& InArgs, IDetailLayoutBuilder* LayoutBuilder, const TSharedRef<IPropertyHandle>& InWindowHeightProperty, const TSharedRef<IPropertyHandle>& InWindowWidthProperty )
{
	check( LayoutBuilder != NULL );

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/LevelEditorPlaySettingsCustomization.cpp:351

Scope (from outer to inner):

file
function     void FLevelEditorPlaySettingsCustomization::CustomizeDetails

Source code excerpt:

		TSharedRef<IPropertyHandle> WindowWidthHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, NewWindowWidth ) );
		TSharedRef<IPropertyHandle> WindowPositionHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, NewWindowPosition ) );
		TSharedRef<IPropertyHandle> CenterNewWindowHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, CenterNewWindow ) );
		TSharedRef<IPropertyHandle> EmulatedDeviceHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, DeviceToEmulate ) );

		WindowHeightHandle->MarkHiddenByCustomization();
		WindowWidthHandle->MarkHiddenByCustomization();
		WindowPositionHandle->MarkHiddenByCustomization();
		CenterNewWindowHandle->MarkHiddenByCustomization();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:506

Scope (from outer to inner):

file
function     ULevelEditorPlaySettings::ULevelEditorPlaySettings

Source code excerpt:

	LaunchConfiguration = EPlayOnLaunchConfiguration::LaunchConfig_Default;
	bAutoCompileBlueprintsOnLaunch = true;
	CenterNewWindow = false;
	NewWindowPosition = FIntPoint::NoneValue; // It will center PIE to the middle of the screen the first time it is run (until the user drag the window somewhere else)

	EnablePIEEnterAndExitSounds = false;

	bShowServerDebugDrawingByDefault = true;
	ServerDebugDrawingColorTintStrength = 0.0f;