- Home /
There is no solutions I think...
Changing button positions on different resolutions
Hi there,
Is there any solution for the following problem?
I have canvas, with the following parameters:
Render mode: screen space - camera - UI Scale Mode: Scale with screen size - Ref. resolution: 1280x1920 - Screen match mode: Match width or height
In this canvas, I have an image where the anchor presets setting is strecth to all the directions (like a background image). The image size is 1280x1920 too, but I think this doesn't matter...
And there is a button in the canvas too. I set this button's position to manually based on the image. (There is something on the image, where I want to place the button). The anchor presets setting is middle/center and the position is e.g.: x = 460, y = 730.
And about the problem:
If I changed the screen resolutions, the button's position stays the same (460/730), but it doesn't mean the same what was in the original resolution so the button moves away.
I know why that happens. The image and button anchor's settings are not the same, but I can't use stretch for the button because in that case, the button will be deformed on other screen resulotions.
Is there any way to solve this issue? E.g.: some matemathical way, to calculate new position to the button; or other settings etc.
I hope what I wrote it's understandable...
Thanks for your help.
I had the same problem, and it was fixed with UI Scale $$anonymous$$ode: Scale with screen size; Screen match mode: Expand
Answer by JackNelson · Nov 01, 2015 at 11:00 PM
Your button isn't linked with your canvas so scaling your canvas won't help, do your best to make sure the button is linked to the canvas.
When I add a button to the scene, is it not linked automatically to the canvas? If not, how should I do that?
I tested it again and unfortunatelly it doesn't work. If I set up different anchor preset for the image and the button the button doesn't stay on the original position when I change the screen resolutions. But when the anchor preset is the same, the button can follow the changes so I think that the button was linked to the canvas as normal.
Follow this Question
Related Questions
Problems with render priority in UI Canvas 2 Answers
How to detect button presses and change child object text in the button's Parent Object script 0 Answers
How to scale according to different mobile resolutions? 0 Answers
Highlighted buttons stay highlighted when I deactivate a canvas. No way to unhighlight them. 1 Answer
How to keep UI button from triggering game objects behind it? 0 Answers