'Unity game on Android phone cuts off edges
I am making a simple platformer in Unity. This is what it looks like in the editor:
You see, it is set to be in landscape in a 16 by 9 ratio. This is just fine.
Now, a few days ago, I updated my JDK to the newest version. Before, my game looked just like that on my Samsung S8. It was centered with black pillars to the left and right of it, since the screen isn't 16:9. This was great.
Now after updating, this is what it now looks like:
I am not sure why Unity does this.
Clearly, the game is now cut off on the top and lower ends so that it keeps its ratio. But this isn't what I want. I want my black pillars back to have everything be on screen and not partly be off screen.
Solution 1:[1]
I solved this problem with next steps:
- PlayerSettings/Aspect Ratio Mode = Legasy(1.86)
- PlayerSettings/Supported Aspect Ratios = 16:9 only
- Canvas Scaler/UI Scale Mode = Scale With Screen Size
- Canvas Scaler/Reference Resolution = any resolution for aspect ratio = 16:9 (1920; 1080)
- Canvas Scaler/Match = 1 (for scale based on height)
- All Cameras/Background = full black
Solution 2:[2]
Fix the resolution and aspect ratio issues directly: add a canvas scaler to the root canvas gameobject.
Basically, force fixed width and let the height vary based on aspect ratio. Make sure all UI is properly anchored from the top or bottom to handle that variation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MainTreeOnMap |
| Solution 2 | Berme |


