I'm new to unity, and i made a game, But it doesn't work with diffrent resolutions. When i edit a button it shows me a little box at the center of the canvas. i've tried many things, but nothing helped me, and buttons are still half on screen half not.
Can someone help me?
CodePudding user response:
There are two things you needed for UI to work with multiple resolution :
First : RectTransform
Second : Canvas Scaler
RectTransform is a position that when you change resolution, the distance between the rect's position to the UI is consistent, by default it is in the center of the screen. You can adjust it by the RectTransform component in your UI
Canvas Scaler : You can use it in the canvas which contain your UI. You can choose the default resolution to scale from, for example, 1920*1080 and then the UI will scale base on the width or height
CodePudding user response:
i found the problem. the button had a parent that limited the RectTransform. I've changed the parent into a completly diffrent canvas, and it worked. I found the answer on this tutorial: https://www.youtube.com/watch?v=FeheZqu85WI.