Search Unity

UWP Portrait, Landscape, and Full Screen

Discussion in 'Windows' started by KevinK2K, Nov 7, 2018.

  1. KevinK2K

    KevinK2K

    Joined:
    Aug 16, 2018
    Posts:
    20
    Hopefully this will be a quick question if anyone wants to provide their thoughts or insights. I've got an Android game that runs in portrait mode, and the nature of it means it must remain in portrait mode. However, I'd like to create a single UWP package that will work both as a full screen portrait mode game where possible (i.e. on a windows phone), but that will then drop into Windowed mode if full screen portrait is not available, such as a desktop or standard laptop (otherwise I will be left with big blank areas at the sides of the screen if it goes into full screen on a landscape device). My thinking is that the best way of doing such a thing would be to set 'requires full screen' and 'portrait mode' in the Unity Editor, and then write some code to measure screen during Awake(), then if the measurements indicate a landscape screen, switch to windowed mode before presenting the first scene (or does a lack of availability of 'portrait mode' then negate the 'requires full screen' parameter across all devices this might occur on?). I've searched this online but only seem to get answers to different questions, then others that kind of fizzle out when getting to the root of what I am asking. I know this is something I can test myself, but can only do so in a very limited fashion as I don't have access to many devices, so I'm wondering if my idea is an acceptable/standard way of doing such a thing which will provide consistency across whatever machine it might run on. Or maybe I'm talking nonsense and seeing a problem where none exists. Thanks in advance.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,441
    Your strategy sounds good, but keep in mind that on UWP you can't enforce window size (you can only set it) - computer user can always resize it as he/she pleases, so you need to implement "black bars" in either case.
     
  3. KevinK2K

    KevinK2K

    Joined:
    Aug 16, 2018
    Posts:
    20
    Thanks for reply. Got the black bars in already to allow for a bit of clipping on mobiles with potentially unusual aspect ratios, so should just need to update that to keep track of the window size on an on-going basis, rather than a one time measurement for fixed screens.