Skip to content

Instantly share code, notes, and snippets.

View TOLINSKI's full-sized avatar

Benski TOLINSKI

View GitHub Profile
@TOLINSKI
TOLINSKI / GettingDPI_Scale_UMG_UE4_example.cpp
Created January 7, 2025 16:34 — forked from JonathanADaley/GettingDPI_Scale_UMG_UE4_example.cpp
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);