I recently set up a Custom DPI Scaling rule for our project in order to change the DPI scaling based on the number of local players we have, however, it turns out it doesn’t work in non-editor builds. Did some investigating, and it seems to be because once the “LastViewportSize” has been set once inside of UUserInterfaceSettings::GetDPIScaleBasedOnSize, it doesn’t get reset, as we Cache that value in non-editor builds.
[Image Removed]
I had a look elsewhere on UDN and found this post from 2023 where it appears the issue is valid and that there were plans to add a “ResetLastViewportSize” function in 5.3, however I’ve not been able to find that anywhere. I’ve made a function locally that I can call to reset the LastViewportSize per the discussion in the previous post, and I now call that when a local player is added/removed from the game, but I just wanted to make sure that this is still the correct way to be doing this, or if something has changed since then and we should be doing something different?
[Content removed]
Hi [mention removed]
It looks like the issue is still present. I’ve reviewed the most recent changes in the engine, and the relevant code structure remains unchanged. I’ll go ahead and notify the development team about this limitation.
Regarding your custom modification, have you encountered any issues so far? If you’d like, feel free to share the code you changed. I can pass it along to Epic for further review to see if there are any concerns with the implementation. Without testing directly, it seems that since LastViewportSize is a TOptional, calling Reset() should be enough to force a reevaluation through GetDPIScaleBasedOnSize.
Best regards,
Joan
Hi [mention removed],
Haven’t encountered any issues with my fix (so far), though we’re quite early in development so it’s one that we’ll monitor (specifically for performance issues). Once change I did make since my original post was to use the split screen layout (found in the GameViewportClient) rather than the number of players, as this allows the UI obey correct scaling rules when splitscreen is force disabled (for menus/cutscenes etc).
Then, in our custom game viewport client class (derived from UCommonGameViewportClient) I overrode the “NotifyPlayerAdded” and “NotifyPlayerRemoved” virtual functions and call the “ResetLastViewportSize” function within each of these functions!
Have attached the custom modification I made, it’s wrapped in the “if !WITH_EDITOR” macro as the issue itself only occurs outside of the editor (as seen in my original post) so wanted to keep things consistent
This code was added in UserInterfaceSettings.h, around lines 226-230 (with our engine change markup comments)
#if !WITH_EDITOR void ResetLastViewportSize() const { LastViewportSize.Reset(); } #endif
Great to hear Chris! Will also update epic with this new information. Thanks! Will update again this thread if I get any information of Epic implementing the asked feature.