In Unity3D I can't scale the game properly to remove the black bar.
I've added pictures for reference:
EDIT: I need to make the canvas scale to the whole screen instead of only a part of the screen.
You should first set your game viewport to simulate the resolution and screen size of whatever you're building for. Change Free Aspect to the appropriate aspect ratio or manually add a new resolution.
Also, I believe the match mode you want for your Canvas Scaler is Match Width or Height.
You have to set anchors of Image to each corner of your canvas display so It can scale accordingly.
Just change the aspect ratio from 'free aspect' to '16:9' or manually enter an aspect ratio that suits your needs.
Cheers.
Try to dynamically spawn the background or image by using Scale To Fit lots of Unity Documentation to help with that so when compiled you can tend to get a stronger and fuller picture this may help with a general sizing issue
Set the screen resolution manually in the Start() of your code:
Screen.SetResolution(x, y, true)
Related
sorry I have to put all of this as an image but I couldn't post this with text as when creating the original post something happened to where it was flagged as spam. I figured this would be the only way?
Unity's UI screen is different from the in-game world space.
For the UI part you can easily fix the issue of the size and position by considering the following:
First thing you need to check is the Canvas Scaler component which is automaticaly generated on your Canvas gameobject.
Canvas Scaler Example
First under The UI Scale Mode you should choose the "Scale with Screen Size" which will make UI elements bigger the bigger the screen is.
Second is the Reference Resolution which is the resolution the UI layout is designed for. If the screen resolution is larger, the UI will be scaled up, and if it's smaller, the UI will be scaled down. A good example is to set the dimensions int something like this (1920x1080) which is the most common landscape resolution.
Third is the Screen Match Mode which is a mode used to scale the canvas area if the aspect ratio of the current resolution doesn't fit the reference resolution. With other words if you change your in-game resolution this will handle your UI elements.
Fourth is Match which will determine if the scaling is using the width or height as reference, or a mix in between. So if your game is in landscape mode you should set it to 0, if it's in portrait mode you should set it to 1.
Last thing to keep in mind that will affect your UI elements position is the Anchor presets which is part of the Rect Transform component on each of your UI elements.
I am making a 3D game on Unity. Currently I work on main menu. The problem is
when I use 16:9 aspect ratio I get this result:
The background is not scaled.
However when I use Free aspect ratio, I get this:
Here is background object properties and sprite properties:
I have no clue what is the problem here and how to solve it. I hope to find some help here. Thanks in advance.
You should extract one tile of the background sprite like this:
Then it should be tiled correctly.
The key is to extract the smallest repeatable element.
Also, you don't have to worry about the Free Aspect. Just make sure it looks fine on the real screen resolutions.
I'm trying to make a level select screen for my game, but when testing the game build the ui isn't scaled that well
I'm currently using the Canvas Scaler with the following settings
These settings give me..interesting results to say the least
What the result is SUPPOSED to be is this
How am I able to do this?
There a few things that you should keep in mind while building the UI for different screens.
Have a target Aspect ratio. Generally it should be 16:9 for landscape and 9:16 for Portrait.
Make sure the reference resolution is in line with your target aspect ratio.
Set the Match option of canvas scalar to 0.5 to scale evenly. If you are sure the device aspect ratio will change in only one direction then set either height or width. For example a portrait game will scale only by height if you switch from 9:16 to 9:18.(0.5 has worked always for me)
Select the aspect ratio in the game window and set the Anchors of the UI to the corner of the UI element. That way Unity will know where the element should be based on Canvas size.
Here is a video that demonstrates it
https://youtu.be/08S1VGL9afg
First of all, use some custom resolution in game view instead of Free Aspect.
Then you could try adjusting Match with Height or width to 0.5.
In some case, you have to adjust custom anchors using these little guys
If you want to absolutely preserve aspects, use this option on Image component.
I would like my UI to be like the first picture, but when I expand it, it turns out like the second picture. How can I fix this?
Under your UI Canvas go to Canvas>Render Mode> and change from Screen Space Overlay to Screen Space Camera
I set my aspect ratio to a fixed one (16:9) and changed the UI Scale Mode to scale with screen size, the match slider below (for resolution) to .5, which seemed to do the trick
First of all, sry for my English mistakes, I'm not a native English speaker.
I'm trying to make an UI which is composed of a canvas within different gameObject, and I would like that my canvas scales to the dimension of the screen but keeps its original resolution (16x9 portrait). If it is displayed on a tablet resolution (4x3) then an image is displayed in the space that is not covered by the canvas.
But actually all I've got is a canvas which scales to every resolution, and it changes the aspect of its child (for example a square becomes a rectangle).
Thank you for showing interest in my query!
UI's are heavy beasts. Canvas in Unity have a component attached to themm called Canvas Scaler which is set by default on Constant Pixel Size. You may try to set this property on Scale With Screen Size and then specify the base resolution you want to work with (usually 1920x1080 is a console standart). This is your first step
Then, to avoid strange Image scaling, you may check the property Preserve Aspect, this way the ration of the Sprite into your Image will remain the same indepently of the ratio of the Image
Last, you may play a bit with anchors but this is another story, you should let those at plain center at the beginning and come back to it when you will feel ready
Hope that helped ;)
Your canvas should have a component called Canvas Scaler. Here it should say Constant Pixel Size, change this to Scale With Screen Size and it should lock the Canvas to be the same width / height as the screen. If you want to lock an image to a specific width/height ratio, go to the Image component on the image and check the Preserve Aspect checkbox. This way if you have a 100x100 image, the images width will always be the same as the height. If you have a 200x100 image, the images width will always be twice the height, etc etc etc.