Changing UI Scale in UE4

UI scaling is a pretty standard feature of modern games. It lets players change how large the UI is shown, and is especially usseful for those playing on 4K monitors or TVs far away.

Luckily in UE4 it’s simple to do in C++, and works alongside any DPI scaling rules you may have.

MyGameplayStatics.h

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "EngineMinimal.h"
#include "MyGameplayStatics.generated.h"

UCLASS()
class UMyGameplayStatics : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	// Custom UI scale 1.0f == 100%, 2.0f == 200%, 0.5f == 50% etc.
	UFUNCTION( BlueprintCallable, Category = "User Interface" )
	static void SetUIScale( float CustomUIScale );
};

MyGameplayStatics.cpp

#include "MyGameplayStatics.h"
#include "Engine/UserInterfaceSettings.h"

void UMyGameplayStatics::SetUIScale( float CustomUIScale )
{
	UUserInterfaceSettings* UISettings = GetMutableDefault<UUserInterfaceSettings>( UUserInterfaceSettings::StaticClass() );

	if ( UISettings )
	{
		UISettings->ApplicationScale = CustomUIScale;
	}
}