NewWindowWidth

NewWindowWidth

#Overview

name: NewWindowWidth

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 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NewWindowWidth is to specify the width of the new viewport window when playing the game in the Unreal Editor. It is primarily used for the Play-in-Editor (PIE) functionality, which allows developers to test their game within the editor environment.

This setting variable is mainly relied upon by the UnrealEd module, specifically within the LevelEditor and PlayInEditor subsystems. It’s used in conjunction with other related settings to control the size and position of the game window during PIE sessions.

The value of this variable is typically set in the project settings, specifically in the “Play” section of the Level Editor settings. It can also be programmatically set in certain scenarios, such as when overriding play settings for movie scene captures.

NewWindowWidth interacts closely with other variables, particularly NewWindowHeight, NewWindowPosition, and CenterNewWindow. These variables work together to define the dimensions and placement of the PIE window.

Developers should be aware that:

  1. Setting this value to 0 will use the desktop’s screen resolution.
  2. The value is clamped to a minimum of 0.
  3. Changes to this value may affect the game’s rendering and UI scaling.

Best practices when using this variable include:

  1. Setting it to match the target platform’s resolution for accurate testing.
  2. Considering it in conjunction with NewWindowHeight to maintain the desired aspect ratio.
  3. Being mindful of how changes to this value might affect performance, especially on less powerful development machines.
  4. Using it in combination with other PIE settings to create a testing environment that closely mimics the target platform.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:224, 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:478

Scope (from outer to inner):

file
function     void FInEditorCapture::OverridePlaySettings

Source code excerpt:

	const FMovieSceneCaptureSettings& Settings = CaptureObject->GetSettings();

	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

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

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject

Source code excerpt:

	/** The width of the new view port window in pixels (0 = use the desktop's screen resolution). */
	UPROPERTY(config, EditAnywhere, Category=GameViewportSettings, meta=(ClampMin=0))
	int32 NewWindowWidth;

	/** The height of the new view port window in pixels (0 = use the desktop's screen resolution). */
	UPROPERTY(config, EditAnywhere, Category=GameViewportSettings, meta=(ClampMin=0))
	int32 NewWindowHeight;

	/** The position of the new view port window on the screen in pixels. */

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

Scope (from outer to inner):

file
function     void UEditorEngine::EndPlayMap

Source code excerpt:

				{
					PlaySettingsConfig->NewWindowPosition = PlaySettingsConfig->MultipleInstancePositions[WindowIndex];
					PlaySettingsConfig->NewWindowWidth = PlaySettingsConfig->LastSize.X;
					PlaySettingsConfig->NewWindowHeight = PlaySettingsConfig->LastSize.Y;
				}
			}
		}

		PlaySettingsConfig->PostEditChange();

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

Scope (from outer to inner):

file
function     void UEditorEngine::StartPlayInEditorSession

Source code excerpt:

	{
		FMargin SafeZoneRatio = EditorPlaySettings->PIESafeZoneOverride;
		SafeZoneRatio.Left /= (EditorPlaySettings->NewWindowWidth / 2.0f);
		SafeZoneRatio.Right /= (EditorPlaySettings->NewWindowWidth / 2.0f);
		SafeZoneRatio.Bottom /= (EditorPlaySettings->NewWindowHeight / 2.0f);
		SafeZoneRatio.Top /= (EditorPlaySettings->NewWindowHeight / 2.0f);
		FSlateApplication::Get().OnDebugSafeZoneChanged.Broadcast(SafeZoneRatio, false);
	}

	{

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

Scope (from outer to inner):

file
function     void UEditorEngine::GetWindowSizeAndPositionForInstanceIndex

Source code excerpt:

	if (InWorldContext.bIsPrimaryPIEInstance)
	{
		OutSize = FIntPoint(InEditorPlaySettings.NewWindowWidth, InEditorPlaySettings.NewWindowHeight);
	}
	else
	{
		// Use the size for additional client windows.
		InEditorPlaySettings.GetClientWindowSize(OutSize);
	}

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

Scope (from outer to inner):

file
function     void UEditorEngine::LaunchNewProcess

Source code excerpt:

		if (NetMode == EPlayNetMode::PIE_Standalone)
		{
			WindowSize.X = InParams.EditorPlaySettings->NewWindowWidth;
			WindowSize.Y = InParams.EditorPlaySettings->NewWindowHeight;
		}
		else
		{
			InParams.EditorPlaySettings->GetClientWindowSize(WindowSize);
		}

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

Scope (from outer to inner):

file
function     void FLevelEditorPlaySettingsCustomization::CustomizeDetails

Source code excerpt:

		// new window resolution
		TSharedRef<IPropertyHandle> WindowHeightHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, NewWindowHeight ) );
		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();

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

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::PostInitProperties

Source code excerpt:

	Super::PostInitProperties();

	NewWindowWidth = FMath::Max(0, NewWindowWidth);
	NewWindowHeight = FMath::Max(0, NewWindowHeight);

	NetworkEmulationSettings.OnPostInitProperties();

#if WITH_EDITOR
	FCoreDelegates::OnSafeFrameChangedEvent.AddUObject(this, &ULevelEditorPlaySettings::UpdateCustomSafeZones);

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

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::UpdateCustomSafeZones

Source code excerpt:

	else
	{
		PIESafeZoneOverride = CalculateCustomUnsafeZones(CustomUnsafeZoneStarts, CustomUnsafeZoneDimensions, DeviceToEmulate, FVector2D(NewWindowWidth, NewWindowHeight));
	}

	if (FSlateApplication::IsInitialized())
	{
		if (bResetCustomSafeZone)
		{

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

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::UpdateCustomSafeZones

Source code excerpt:

		{
			FMargin SafeZoneRatio = PIESafeZoneOverride;
			SafeZoneRatio.Left /= (NewWindowWidth / 2.0f);
			SafeZoneRatio.Right /= (NewWindowWidth / 2.0f);
			SafeZoneRatio.Bottom /= (NewWindowHeight / 2.0f);
			SafeZoneRatio.Top /= (NewWindowHeight / 2.0f);
			FSlateApplication::Get().OnDebugSafeZoneChanged.Broadcast(SafeZoneRatio, true);
		}
	}
}