DesignScreenSize

DesignScreenSize

#Overview

name: DesignScreenSize

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

#Summary

#Usage in the C++ source code

The purpose of DesignScreenSize is to define the native resolution for which the source UI textures were created in Unreal Engine 5. It is primarily used with the ScaleToFit scaling rule for DPI scaling in the user interface system.

This setting variable is part of the Unreal Engine’s user interface system and is specifically used in the UserInterfaceSettings module. It’s referenced in the UUserInterfaceSettings class, which is derived from UDeveloperSettings.

The value of this variable is set in the UUserInterfaceSettings class declaration with a default value of FIntPoint(1920, 1080), representing a 1080p resolution. However, it can be configured through the Unreal Engine editor or project settings.

DesignScreenSize interacts with the EUIScalingRule enum, particularly the ScaleToFit option. It’s used in calculations to determine the appropriate scaling factor for UI elements based on the current screen size.

Developers must be aware that this variable is crucial for maintaining consistent UI scaling across different screen resolutions. It serves as the baseline for calculating the scale factor when using the ScaleToFit scaling rule.

Best practices when using this variable include:

  1. Setting it to match the resolution of your source UI assets.
  2. Ensuring it’s appropriately set when using the ScaleToFit scaling rule.
  3. Considering it when designing UI layouts to ensure proper scaling on various screen sizes.
  4. Regularly testing UI scaling on different resolutions to verify that the DesignScreenSize is set correctly for your project’s needs.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:242, section: [/Script/Engine.UserInterfaceSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/UserInterfaceSettings.h:39

Scope: file

Source code excerpt:

	/** Evaluates the scale curve based on the Y axis of the viewport. */
	Vertical,
	/** ScaleToFit - Does not use scale curve. Emulates behavior of scale box by using DesignScreenSize and scaling the content relatively to it. */
	ScaleToFit,
	/** Custom - Allows custom rule interpretation. */
	Custom
};

/** The most used DPI value. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/UserInterfaceSettings.h:197

Scope (from outer to inner):

file
class        class UUserInterfaceSettings : public UDeveloperSettings

Source code excerpt:

	/** Used only with ScaleToFit scaling rule. Defines native resolution for which were source UI textures created. DPI scaling will be 1.0 at this screen resolution. */
	UPROPERTY(config, EditAnywhere, Category="DPI Scaling|Scale To Fit Rule", meta=( DisplayName="Design Screen Size", ClampMin="1", UIMin="1" ))
	FIntPoint DesignScreenSize = FIntPoint(1920, 1080);

	/**
	 * If false, widget references will be stripped during cook for server builds and not loaded at runtime.
	 */
	UPROPERTY(config, EditAnywhere, Category = "Widgets")
	bool bLoadWidgetsOnDedicatedServer;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterfaceSettings.cpp:151

Scope (from outer to inner):

file
function     float UUserInterfaceSettings::CalculateScale

Source code excerpt:

			break;
		case EUIScalingRule::ScaleToFit:
			return DesignScreenSize.X > 0 && DesignScreenSize.Y > 0 ? FMath::Min((float)(Size.X) / DesignScreenSize.X, (float)(Size.Y) / DesignScreenSize.Y) : 1.f;
		}

		const FRichCurve* DPICurve = UIScaleCurve.GetRichCurveConst();
		return DPICurve->Eval((float)EvalPoint, 1.0f);
	}
}