Hi, we’re looking into the possibility of setting a global UI scale multiplier at runtime and I’m trying to understand what the intended way to accomplish this is. Looking through the code/EPS, I see two candidates that looked promising: setting UUserInterfaceSettings::ApplicationScale and calling FSlateApplication::Get().SetApplicationScale(). However, neither of these actually seem to update the scale of widgets in the packaged game.
Is there another step we need to perform here to get the UI to actually update or is there an alternate method that the engine is expecting us to call?
Thanks.
Hi,
Either of those should work, with a slight preference towards UUserInterfaceSettings since it will be stored in your engine config file (vs. needing to be reapplied at runtime). You can either set that in the editor (Project Settings->Engine - User Interface->DPI Scaling->Application Scale) or use GetMutableDefault<UUserInterfaceSettings> to access and change the value at runtime, calling SaveConfig to push any user-modified settings back to the ini file.
This value ultimately gets applied at the GameLayerManager level in SGameLayerManager::GetGameViewportDPIScale, so if you aren’t seeing any changes then you could drop some logging in there to investigate. You mentioned it isn’t updating the scale in a packaged game, does that mean it is working as expected in the editor? If not, could some widget in your hierarchy be applying inverse scaling? As a sanity check I packaged Lyra with a modified ApplicationScale and it seemed to take, the GameLayerManager has a SDPIScaler widget bound to GetGameViewportDPIScale so it should automatically react to any changes in the return value there. If you have global invalidation enabled, it may be worth disabling that temporarily to see if it’s a factor.
Best,
Cody
Ah, thanks for mentioning a widget potentially applying inverse scaling. I took a look up the widget hierarchy and it looks like one of our UI artists used a scale box that has the side effect of counteracting the DPI scaling being applied. Removing that allows setting UUserInterfaceSettings::ApplicationScale to work as expected, so I’ll discuss with them what the intent was and try to find an alternative way of achieving it. Thanks!