This isn't really a code issue, its more of a wtf is this not working, I always have this problem where ui does not stay in the position I want it to (yes, I use scale and not offsets, for scale and position) I figured out how to stop it from stretching, but not moving. Problem is in pictures here -> Imgur Thanks!
UI wont stay in the correct position, any clue why?
1 answer
From what I can see in your image you're changing the size of the screen (by screen I mean the screen which is displaying the game) and this is causing the UI to change move around the screen?
This is happening because you are using scale to define your UI (intended behaviour). If your position is set to {0,0,0,0} (and anchor point 0,0) then the box will display in the top left but if your position is set to {0.1, 0, 0.1, 0} (only the scale component has changed) then the box will display 10% of the way across your screen and 10% of the way down your screen. If you dont understand read this
If you really want the UI to stay in the same spot regardless of screen size I guess you could read from absolute position, print out the result and then manually put it into the offset component but that would not work well for different sized screens etc.
Good luck, I hope this answered your question. If you need more help please elaborate on your question.
3 comments
No, didn't help, I already understand how that stuff works, but the issue is that I want it to not move around the screen like shown, it would be fine if it was only one ui element but its many and going to be a LOT more, as it will be the player's inventory.
What is causing them to change? Are you changing the size of the screen or is something else happening? Those images don't really explain what the difference is
Yeah, I am trying to keep it the same based on the size of the screen, I was thinking I would write a script to fetch the aspect ratio to change the positions based on that.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Use a UIListLayout.
I know you just said this in your question, but have you checked whether every single frame uses scaling (and not pixel) offsets? Sometimes pixel offsets are useful for fixed distances between UI objects, perhaps.
Nevermind, I've found the issue, from what I've seen, the aspect ratio is different, but the UI -size- is still in a constraint, the -position- isn't accomodated to account for this.