Hello,
When I make the UI element and place it in the 2D screen on X: 240, Y: -840 in 1920x1080 resoulution if I run the game on mobile it’s local position will still be X: 240 and Y: -840. Is there an easy way to calculate it’s real position on different resolutions or do I have to calculate the position myself?
Image showing what I mean:
Do I need to recalculate it’s position depending on current resolution and general resolution?
UI in screenspace will be scaled according to the size and aspect ratio.
So the local position should still be the same across all resolutions from it’s anchor. The whole UI is scaled to fit the screen.
If you want the real screen position, use https://developer.playcanvas.com/api/pc.ElementComponent.html#canvasCorners which will return an array of the 4 positions of the corners of the element on the web canvas
2 Likes
Aha, got it.
I didn’t even see that in documentation. Thank you very much @yaustar! Can’t put “SOLVED” or I can’t find it.