Skip to content

Instantly share code, notes, and snippets.

View JonathanADaley's full-sized avatar

Jon Daley JonathanADaley

View GitHub Profile
@JonathanADaley
JonathanADaley / GettingDPI_Scale_UMG_UE4_example.cpp
Last active September 11, 2023 06:57
How to get the DPI Scale of UMG at runtime in Unreal Engine 4 C++
// this function requires the UserInterfaceSettings header to be included
#include Runtime/Engine/Classes/Engine/UserInterfaceSettings.h
// this function can be marked as Blueprint Pure in its declaration, as it simply returns a float
float MyBPFL::GetUMG_DPI_Scale() {
// need a variable here to pass to the GetViewportSize function
FVector2D viewportSize;
// as this function returns through the parameter, we just need to call it by passing in our FVector2D variable
GEngine->GameViewport->GetViewportSize(viewportSize);