- Home /
Problem with fixed Resolution and UI anchoring
I have a problem when it comes to ui anchoring and fixed resolution. In my example I have 2 buttons one anchored at the top of the screen and and one at the bottom. The Canvas has Canvas scaler (Scale with UI size) match height 1. Reference resolution 1024x640
So in the first image where I use aspect ratio 16:10 everything works as it should, i.e. the buttons are anchored at the top and bottom of the screen. But something strange happens when I change the resolution to 1024x640 as we see in the second image
First thing we see is that for some reason the scale of the game view becomes 0.93. But when I set it to 1 which is what I see when I build the game. The buttons are cut off the screen. Why is that happening?
UPDATE** It seems that this problem does not appear on every device. My laptop has screen resolution 1366x768 and the UI at the WEBGL still has the problem. I tried it on a computer with 1920x1080 resolution and the UI was fine.
$$anonymous$$ake sure you build your UI in the largest possible screen size you want (also start setting it up when you decide on a Sutible screen size.) From there set the Canvas Scaler to "scale with Screen size" and set "$$anonymous$$atch" to 0.5. $$anonymous$$ake sure the Reference Resoloution is the biggest resolution you want and make sure your Display is set to that resolution. Test and see if that works
The largest possible screen I want is 1024x640 and the Display is 1024x640 (it is a WebGL project) and I have set Canvas Scaler to "Scale with Screen Size" but with "$$anonymous$$atch" 1 but that does not solve my problem.
Ok I've done a bit of playing around with the UI and I think I might know what's going on. The Scaler slider above the game is set to 0.93 because that's how the UI fits. When you build your game it will use the 0.93 for the UI but everything else will be rendered normally. $$anonymous$$G. The scene behind the UI will be 1. So there's no need to worry about the scaler above the Game View.
Just as a note: That Slider above the screen is just a zoom function. It's used if you want too see something in more detail but otherwise i would suggest it remains all the way to the left.
Check out this link. $$anonymous$$aybe it'll help more.
You might also notice the black edges of the screen where the Game isn't rendered due to the resolution. (The sides) That'll go also when the game is full screen and has been built.
Build you game and test if the resolution is right and if the UI is correctly rendered.
Try and set up the buttons again but using the 1024: 640 resolution. Then try and change to the resolution to a lower resolution ( maybe even higher resolution). If it remains working then I got no clue as to why it wasn't working. $$anonymous$$aybe your pivots weren't set right. Ensure that when you assigned the Anchors use shift and alt to assign pivots and set it to the position.
Thanks for the suggestion but it didn't work. I have worked quite a bit with Unity's UI so checking if the anchors are correct was one of the first things I did. Also check at the Update I did if it helps you understand what is happening.
Answer by Oana · Feb 18, 2017 at 07:08 AM
It sounds like in the 1024x640 version it doesn't fully fit into your game view, so it gets scaled down, and if you scale it up to 1, then parts of it will be off the game view window.
Could you try pressing "maximize on play" to confirm that it does look ok at a scale of 1? If my suspicion is correct, then it's working as expected and it will look fine on your device.
I have ran the game with the "maximized on play" pressed and also built the game. The problem persists in both cases. There is an Update in my initial post if it helps. Thanks
Have you tried setting the Pivots when setting the anchors?
Answer by Cipher123 · Jun 21, 2018 at 06:09 AM
follow this link will solve your problem https://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html