Current DPI Scaling

I needed to set an actor on top of some of my UMG widgets so I was facing the same issues since apparently we can’t get widget world location. And so whenever the screen resolution changed, my actor was not at the relative location of my widget buttons like I wanted it. So I turned to the DPI curve, and like you, couldn’t find a way to actually retrieve it using blueprints. So instead I found a way to fake it and get the desired result, although it feels a bit hack-ish, it works well.

Ok, so below I show my DPI curve in the interface settings. Using that information, I built a similar curve in a timeline. The top value is the value that tries to match the viewport size. So I have the same keyframs then in my DPI curve using the screen resolution as values. Below I have another value which aims to find the DPI scale that we need to set our actors according to screen rez. Again I used the same values then in my DPI curve i.e. 0,44444 - 0,666666 - 1.0
What is important here is that both values match in time, so that the keyframe with value 480 happens at the same time as the keyframe with the value 0.44444. Originally I had tried to set the time line to be pretty short so as not to lose to much time calculating. But this made the results innacurate as it was too frame dependant. So I stretched my 3 first keyframes to 4 seconds. The last keyframe 8 I put because it was on my DPI curve but my game doesn’t use platforms that have that kind of resolution so I ignored much past 4 seconds.

So once I start the timeline, I update a compare float with my top value called DPI with the viewport size y. When the timeline finds a match (or close) it tells the timeline to stop, which leaves me with the bottom value called Scale which ends up being my DPI scale. In all trials the difference was always .1 and less of the actual value. So it isn’t 100% precise, but pretty close.

With all that said, hopefully an easier way will be available in future updates. And if anyone has a better way to do it, awesome!