I'm working in Unity, and something stuck in my mind. What is the difference between the UI Scale Mode options in the section of the canvas scaler component, can anyone explain it?
There are 3 UI Scale Mode options. Which of these 3 options should I use and what do they do?
Thanks in advance
You can check here for a more detailed explanation of each field: https://docs.unity3d.com/Packages/com.unity.ugui#1.0/manual/script-CanvasScaler.html
But basically:
Constant Pixel Size: means the UI elements will have the same pixel size always, no matter what size of screen do you have. So if you have a 100px X 100px button on your screen at 1920x1080 it will fill just a small portion of your screen, but if your screen resolution changes to 200x200 for example, than the button will be giant and fill a much bigger part of the screen now.
Scale With Screen Size: means exactly what it says, the UI will scale according to the screen size, so if you work and create your UI on a 960x540 screen and then change to 1920x1080 for example, your UI will scale, and in this case make the UI 2 times bigger because the screen is now 2 times bigger, so the aspect of the button will appear the same in all resolutions.
Constant Physical Size: uses DPI instead of pixels. DPI means "dots (pixels) per inch", meaning you it doesn't matter what the size of your screen is, the amount of pixels you define the UI will cover will remain the same, so for example if you have a 1920x1080 screen, and a 200x100 button, the button will be small on the screen, but if you play the game in a cellphone with lower resolution, 1280x720 for example, the button will remain with the same pixel density, 200x100, but since the screen has less pixels now the button will appear bigger, but in reality the resolution of the button in both cases remains the same.
But all of them also change the way anchors will work on your UI. The best way to know what you should use and what each one does is by testing yourself.
You can read more here as well for more information: https://docs.unity3d.com/Packages/com.unity.ugui#1.0/manual/HOWTO-UIMultiResolution.html
Related
Started learning WPF and after WinForm I have a lot of questions. For example, here are two of them:
Why, when I set the window size to 300x300 pixels, it is smaller when compiled - it turns out 286x293 pixels (if you set it to 200x200, it will actually be 186x193), it always decreases by 14 and 7 pixels.
How can I make the designer display the actual size of the form, and not the enlarged one?
I have a scrollable control whose content sometimes requires the scrollbars to be operational depending on what display the user is using to see the View. So, for example, if the View is being displayed on a laptop screen it will most likely have scroll bars in operation. Whereas, on a 27" monitor all will be visible with no scrollbars present.
What I would like to be able to do is calculate a scale factor that I can use in a ScaleTransform on the ScrollableControl so that the contents are completely visible on screen (what ever that screen happens to be). But I don't know how to do this?
I am aware that I could simply wrap the ScrollableControl with a ViewBox, but my users want to be able to vary the scale factor, so I am using a slider and a ScaleTranform to give them this effect. However, I would like to initialise the slider with the ScaleFactor that I am seeking help with so the View starts off with everything on screen.
I have discovered the System Parameters type which looks to have some useful screen dimension properties, but I'm still confused about how to apply them to work out the scale factor.
Could someone check why my game screen does not maximize on some devices?
Look at the screenshot :
You see the black background and some UI buttons which should be hidden are appearing? The game background is not maximized on some devices.
I am using 1280 x 720 Resolution. I have set a Pivot and Anchor Point In the Rect Transform. But it seems some devices don't display it well.
What should I do to have it maximized on all device? Any ideas?
Thanks
Dennis
I guess you are using UGUI (Unity's built-in GUI system).
Looks like the resulting screen does not match the aspect ratio you used for the UI, so it just rescales evenly until it fits the screen horizontally.
As you can see from the image below, You can have your UI elements scale to fit the screen following different criteria.
Rect Transform Anchors Presets:
If you want your UI to perfectly fit the screen and you don't mind some vertical stretch you might just use the bottom-right option.
However, it's always better to keep in mind the "safe areas" when you design your UI.
It's a concept related to TV screens, but I find it extremely useful for mobile products as well, you can get more info here
You should check if your canvas scaling is maybe set to 0.5 width and 0.5 heigth.
you should change it to 0.0 width and 1.0 heigth.
Also make sure your anchors is right. For the ui part i would write a manager which disables and shows ui based on game states.
hope it helps xD
I am trying to make a game scene for Unity. However, I can't seem to get rid of this border. Or I can't seem to stretch my background to fit the whole screen. I need this scaling to work for all screen sizes. Here is an image of what is happening.
You can clearly see the blue edging, when I don't want that to be happening. This happens when I test on my Tablet as well. The camera is of size 5, however, when I do some debugging, I notice it gives me positions such as 7.15 when I touch on the screen. How can I scale everything down, I have searched through tons of forums and no one seems to be having this issue.
Are you using UI panel for the background? if so try these step.
1st strech the background Panel to fit the whole canvas size
then change the background panel to stretch in all directions
Then select the canvas object and render mode for screen space camera, assign your camera to it and change the UI scale mode to 'scale with Screen size'
How can I make a WPF window (And its controls) have the same size, in pixels, regardless of the system DPI/scale?
My application determines its width and height based on the screen size, and will scale the content area automatically. I'd the controls to appear to all be at the standard "Smaller (100%)" scale.
Currently my application will scale up when on "Medium" or "Larger". I understand this is how WPF is designed to work, but I want to force it to not scale at higher scales. Changing the "DPI Aware" property in the application will have no affect on the size of it, just whether or not it is scaled properly vs being blurry due to being stretched.
If I have a small laptop screen with the default (100%) scale, and a desktop with a 1080p display at 125%, I want the controls to be the same size, pixel wise. This will make the application smaller on the 1080p screen, but my application will increase it's size to make it appear bigger. (The controls will be the same size in pixels, but the main area of my application, a canvas that can be drawn on, will be larger)