Update Widget Postion in Viewport when Viewport Scale Changes

I have a Widget in Viewport that can be re-positioned in Viewport by user by dragging the widget.

I have code keeping the widget inside viewport when being dragged, however, if size of viewport is changed (User Resizes Game Window), the widget will disappear from the viewport, until viewport is resized to a size that will reveal the widget.

The only way I can think to solve this, is to run code on tick to check if widget is within viewport, and if not, move widget accordingly.

Is there some sort of event I can call in Blueprints in the Widget when the viewport size changes? Or perhaps inside the Game Instance, Game Mode or HUD Blueprints?

I really want to avoid tick if at all possible, but am not finding a way around this in this situation?

Blueprint Only

Hello @blindminds

I just took a quick look into the code and I didn’t find any such event for blueprints. Except for this one in GameUserSettings named OnGameUserSettingsUINeedsUpdate but it didn’t run for me and I had problems figuring out why in a short time (you can try to check if it runs in a packaged game or something).

One quick tick function won’t hurt your performance, trust me, and if you insist, then use C++ and the event is super easy to access via the viewport class. Good luck!

Kind regards,
Taberu

This is very promising! I would have NEVER discovered this!

Did a quick test, and print strings gets printed when I resize viewport! So, should work perfectly! Thank You!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.