Executable dimensions not matching Unity IDE dimensions

I have just completed my Laser Defender section of the course, and when I compile it as a Windows executable I am having a problem. The space to the left and right of the “game” has the background color of the canvas, and I can move my ship in it. Other game elements such as the particle effects and enemies can as well.

I looked on the forums, and people have had similar problems, some with oddities in text placement which I am not having. Others suggested an Asset from the Unity store, which although free, doesn’t help me understand what is going on.

I have set my three game screens to 9:16, and all the canvases to 1080 x 1920. I get the exact behavior I want in the Unity IDE, and the canvas items in my Windows builds are where I would expect them.

Can anyone point me to a resource that will help me and, more importantly, explain the “why” behind it? Thanks in advance!

Hi,

Our game was designed for a fixed aspect ratio. 1080 x 1920 means that your game screen is 1920 pixels high. What is the resolution of your sceen?

Make sure that a fixed resolution which matches the aspect ratio was set in File > Build Settings > Player Settings.

Maybe you will have to delete the PlayerPrefs before building.


See also:

I had played around with the File > Build Settings > Player > Resolution and Presentation settings a bunch before posting.

I believe that I could get it working if I forced it to be a non-resizable windowed application (although I haven’t tried), but that seems to be quite limiting.

If you tell me that in real-life applications you have to program in limits of movement and vision outside the desired screen area, then I understand that. It just seems that it would be the sort of thing that Unity would do with the right options.

Try that. Our game is not responsive. For this reason, you are not limiting anything in this respect.

If you wanted to have a more flexible game, you would have to write a custom solution that rearranges the elements in your game screen to achieve pleasant results. Unity does not automatically rearrange anything for you.

Thank you! Just needed to hear that :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms