UMG incorrectly positioning widgets
...that, or the "Viewport Size" node returns incorrect values.
I'm trying to place a lock-on cursor and running into some issues. In the pursuit of debugging the problem, I discovered a really irritating bug: positioning a Canvas slot doesn't ACTUALLY reflect the proper screen size!
See attached pic:
As you can see, I'm PrintString-ing the Viewport X dimension to prove a point: PIE, the dimensions are 1291 x (something). So, for a widget Anchored to the upper-left of the Root Canvas, and with Alignment set to 0.5 x 0.5, this widget SHOULD appear centered over whatever screen dimensions I feed it. Right?
But, see here: I manually feed it a position of 1290. Now, with the reported Viewport size, that should place it halfway off the screen on the right side (with the center of the widget right at the edge of the viewport) Instead, the game just sort of shoves it over. Arbitrarily, it takes an X value of about 1540 to ACTUALLY place the widget on the edge of the screen; this value doesn't seem to be related to anything at all (since not only is it not the viewport's size, but the canvas and game target are 1920x1080, so it's not related to any underlying assumptions about resolution)
I cannot for the life of me figure out why this thing is acting like this. It seems to me that if I feed it screen coordinates, it should appear at those coordinates, but instead it seems to do some sort of arbitrary adjusting of the screen dimensions.
asked Nov 10 '14 at 10:41 PM in Bug Reports
I would like to start off by saying that both the node "Set Position" and "Get Viewport Size" are working correctly. This being said, it is due to the fact that the "Set position" node goes off of the canvas panel's size(1920X1080). Whereas the "Get Viewport Size" is going by the resolution of the viewport (which varies depending on your settings). I have an easy mathematical workaround you can use. Please note that this only works if you have your widget anchored is the upper left corner. Canvas Size Divided by Viewport Size and then multiplied by the actual position you would like to end up with. I hope this helps.
Make it a great day
answered Nov 11 '14 at 05:18 PM
Rudy Q ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here