Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

UI wont stay in the correct position, any clue why?

Asked by 4 years ago

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!

0
Use a UIListLayout. Ziffixture 6913 — 4y
0
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. desperateforthelols 35 — 4y
0
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. desperateforthelols 35 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
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. Karb_arus 2 — 4y
0
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 AlexTheCreator 461 — 4y
0
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. Karb_arus 2 — 4y
Ad

Answer this question