0
\$\begingroup\$

When I build and run my game, the resolution is different than in editor.

Note: My monitor's display settings are 2560 x 1440.

My editor's game display is set to Full HD (1920 x 1080). enter image description here

I have UI positioned just outside of my canvas so that it does not display until needed: enter image description here

This looks fine in the editor and the UI is not visible.

When I build my game using the settings:

Edit > Project Settings > Player > Fullscreen Mode > Exclusive Fullscreen This is what I see: enter image description here

Changing Fullscreen Mode to Windowed and specifying 1920 x 1080, makes it display correctly. enter image description here

But then if I maximize the window using the above settings it displays incorrectly again: enter image description here

Additionally, here is my canvas: enter image description here

I'd like my game to always look the same, displaying in 1920 x 1080 resolution. So, even if the window is maximized, it will just stretch the image, rather than show more of the game, revealing the UI.

Is any one able to provide me with the correct settings I should be using? Thanks so much!

\$\endgroup\$
9
  • \$\begingroup\$ Does this help for your use case? How to force keep the aspect ratio and specific resolution without stretching the output screen view? \$\endgroup\$
    – DMGregory
    Feb 4, 2023 at 12:03
  • \$\begingroup\$ Thanks for the reply! :) To clarify, when you say "For desktop games you can control the supported aspect ratios directly in Edit -> Project Settings -> Player -> Resolution and Presentation" Wouldn't this include my issue as well? None of the 'Full screen Mode' options seem to resolve this. If not, do you recommend I add the CameraCrop script to my Main Camera? The script forces the 16:9 aspect ratio, right? I'm pretty certain that my game is already keeping the 16:9 aspect ratio. I believe the actual issue is that it's showing in 2560 x 1440, rather than 1920 x 1080. \$\endgroup\$ Feb 4, 2023 at 19:41
  • 1
    \$\begingroup\$ How have you configured the Canvas Scaler for your game UI? \$\endgroup\$
    – DMGregory
    Feb 4, 2023 at 19:43
  • 1
    \$\begingroup\$ By saying "Constant pixel size" you're telling Unity "don't increase the size and spacing of my UI on larger screens". Is that really what you want? If so, you might just need to adjust the anchor position of your off-screen elements, to ensure they're positioned relative to the edge of the screen, not relative to the center/far corner. \$\endgroup\$
    – DMGregory
    Feb 4, 2023 at 19:50
  • 1
    \$\begingroup\$ "The same" is not on the table. You have an output with more pixels, so something has to be different. You could scale it up ("Scale with screen size"), or you could leave your UI small and have bigger gaps between items. \$\endgroup\$
    – DMGregory
    Feb 4, 2023 at 21:04

1 Answer 1

1
\$\begingroup\$

The issue was my Canvas Scaler not being configured correctly.

This was resolved by changing my Canvas Scaler's UI Scale Mode from 'Constant Pixel size' to 'Scale With Screen Size'.

Additionally, I set the 'Reference Resolution' to 1920 x 1080 ( the resolution I'm targeting ), and 'Screen Match Mode' to Expand.

This seems to do the trick for me!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Don't forget to mark this answer as "Accepted" if it worked for you. Click the checkmark icon to the left. \$\endgroup\$
    – DMGregory
    Jan 8 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .