- Home /
Canvas Scalar Scale with Screen Size Bug
I have a UI image that takes the top 20% of the screen. I've set the Canvas Scaler to scale with screen size and set reference resolution to 1920x1080. The screen match mode is shrink and reference pixel per unit is at default (100).
As I scale the game scene the ui scales with it. It will stretch and shrink maintaining a 20% coverage of the top. This is what I want.
However when I build and run the scene and choose different resolutions it doesn't scale with the resolution. Instead is seems to keep a constant physical size or pixel size.
According to http://docs.unity3d.com/Manual/script-CanvasScaler.html it should scale with the screen size to keep the same coverage. So is this a bug or am I missing something. If so please comment what it is. I'm using Unity 5.3.1f.
I've noticed this problem too, (Unity 5.3.1f) I hope they'll fix it soon.
Same here. It worked fine this morning before I updated Unity to 5.3. I've tried different "cheats". I've made a coroutine which switches the resolution, then disables/enables canvas scaler component, or change some parameters. I did it in hope that the changes will trigger it to "refresh". But it didn't help :( Any news on this?
One year later: also noticed this bug using reference resolution 1024 x 768 ("Scale with Screen Size", "$$anonymous$$atch Width or Height" option selected). Works perfectly fine in the editor, but is broken in all builds. Using Unity 5.4.2f2, so the mentioned patch of 5.3.1p3 should be in effect but ... doesn't work. Also tried the mentioned workarounds by switching resolutions, enabling / disabling canvas and canvas scaler, changing the reference resolution - nothing worked.
If you're on Unity 5.4.2f2 then you really should update. Unity 5.6 just came out 3 days ago and it has lots of bug fixes and cool new features such as better pathfinding and lighting. Try updating and see if that fixes it.
Updated to 5.6.0f3, issue still there (so, i think this is a self-made-issue, not a Unity bug - but that doesn't fix my UI ;-) ) Switched Canvas to "Constant Pixel Size" and playing around with the Canvas' Scale Factor, but also noticing the same issue here. Not the entire UI is affected, though. Only prefabs, which are added by script during runtime and use the Unity UI Layout (vertical and horizontal layout groups), show this strange behaviour. UI elements, which were added within the editor and / or don't use the Unity UI Layout, are scaled perfectly fine when changing the Scale Factor.
Answer by wlad_s · Jan 20, 2016 at 02:05 PM
As karl.jones says here: http://forum.unity3d.com/threads/canvas-scaler-broken-in-unity-5-3-1f1.380809/
This is fixed in 5.3.1p3. http://unity3d.com/unity/qa/patch-releases
Answer by Fetelava · Nov 06, 2016 at 09:14 AM
I Fixed IT By Changing Reference Resolutions by 1 Pixel.
for example instead of 1920 x 1080 try 1921 x1081
Answer by anileapen05 · Dec 26, 2017 at 05:02 PM
please check this video
Unity UI Tutorial - Scale UI to the right size for every resolution using anchors
Your answer
Follow this Question
Related Questions
UI not scaling correctly with screen resolution 1 Answer
How to scale according to different mobile resolutions? 0 Answers
canvas group breaks button 0 Answers
World Space Canvas Bug? 0 Answers
Canvas is low resolution unless paused and resumed 0 Answers