Search Unity

Screen.currentResolution returning wrong value on startup

Discussion in '2D' started by wcburg1, Jul 4, 2020.

  1. wcburg1

    wcburg1

    Joined:
    Mar 23, 2018
    Posts:
    19
    I'm having a strange issue where Screen.currentResolution returns a different value when it first starts up my game from when the game is running. Basically when I Build and Run (on Android) and it starts up the game from the first scene, the Screen.currentResolution gives an incorrect value. If I navigate to another scene within the game and then return to the first scene, it returns the correct Screen.currentResolution value. It only returns the incorrect value when it first loads to first scene in the game.
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Are you checking the resolution on Awake? Some things you need to wait until Start to check. AudioMixer isn't quite setup until Start, trying to change parameters for it in Awake doesn't work.
     
  3. wcburg1

    wcburg1

    Joined:
    Mar 23, 2018
    Posts:
    19
    Yep I tried both Start and Awake. Both have the same problem.
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    I would try to test it making Start a coroutine and testing every frame to see if it changes. It could be a bug. I've had some issues with reported screen resolutions in the past that I couldn't figure out. Like the game choosing 1920x1080 @ 60hz, the native resolution, but doesn't list it in the available resolutions. So if the user changes the resolution they have no way of going back to the native resolution.