Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Failed to reduce screen resolution on Lumia 950 phone by code

Discussion in 'Windows' started by sdkfz250, Dec 26, 2015.

  1. sdkfz250

    sdkfz250

    Joined:
    Apr 17, 2015
    Posts:
    15
    Hello,

    Within my game, I am trying to reduce the native screen resolution of my Lumia 950 (Windows Phone 10) from 2560x1440 to 1920x1080 (Unity 5.3.1) with the following code:

    if (Application.platform == RuntimePlatform.WSAPlayerARM) {
    Screen.SetResolution (1920, 1080, true);
    }

    The code results in strange display behavior (one of the button Icons fills the entire screen) and then the screen resolution jumps back to native 2560x1440.
    I am compiling with Windows Store/Phone 8.1.

    Any comments on what I am doing wrong? Many thanks in advance and sorry for my English.

    Michael
     
    Last edited: Dec 27, 2015
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,673
    This may be a bug, could you check what value is QualitySettings.antiAliasing, and try changing it before Screen.SetResolution (1920, 1080, true);, for ex., set value 0 or 2
     
  3. sdkfz250

    sdkfz250

    Joined:
    Apr 17, 2015
    Posts:
    15
    Hi Tomas1856,

    thanks, your tip worked. I implemented "QualitySettings.antiAliasing = 2" before "Screen.SetResolution (1920, 1080, true)" and now Screen Resolution is properly set to 1920x1080.

    Many thanks

    Michael
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,673
    Cool, then it's the same bug, it will be fixed in upcoming patch release - 5.3.1 Patch 3
     
  5. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Hi guys
    We have the same "issue" but compiling with Windows Store / Universal 10 mode on Lumia 950...
    The given workaround dont work (we tried from Unity 5.3.1f to 5.3.2p4), any tricks/chanve to change resolution on Universal 10 Unity games ? ?
     
    Last edited: Feb 24, 2016
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    Did you try a later release? As Tomas said, it has been fixed recently.
     
  7. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Thanks for your quick reply !
    Based on you post here ...
    ...we tried on the last patch release 5.3.2p4 (but I'm installing the 5.3.2p2 to test it just in case ^^)

    more news soon
     
    Last edited: Feb 24, 2016
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    So what exactly happens when you try changing the resolution? Could you show your code that does it?
     
  9. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Here the code :
    Code (CSharp):
    1.  
    2. Debug.LogError("[Screen] Current Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height );
    3. int height = Screen.currentResolution.height;
    4. if ( height > 1080){ // Lumia 950
    5.   QualitySettings.antiAliasing = 0;
    6.   Screen.SetResolution(1920, 1080, true);
    7.   Debug.LogError("[Screen] Reset Resolution to 1920x1080");
    8. } else if (height > 720) { // 1080p devices...
    9.   QualitySettings.antiAliasing = 0;
    10.   Screen.SetResolution(1280, 720, true);
    11.   Debug.LogError("[Screen] Reset Resolution to 1280x720");
    12. }else{ // Lumia 650, 550
    13.   QualitySettings.antiAliasing = 0;
    14.   Screen.SetResolution(1024, 576, true);
    15.   Debug.LogError("[Screen] Reset Resolution to 1024x576");
    16. }
    17. Debug.LogError("[Screen] Final Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height );
    18.  
    We tried to switch Lumia 550's resolution from 720p to 576p; and Lumia 950's resolution from "2.5k" to 1080p, with Unity 5.3.2f1 & Unity 5.3.2p4 but without success...

    Lumia 950 output :
    I'm finishing to install 5.3.2p2 to try ...
     
  10. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    So, exactly the same issue with 5.3.2p2...

     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    Check the actual resolution next frame. SetResolution doesn't change the resolution immediately, it merely notes that you want to change it. The actual resolution change occurs at the end of frame.
     
  12. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    I tried the frame after, the second after ... same result ... :(
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    We'll look into it.
     
    Namal likes this.
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    I can confirm it doesn't work on phone for some reason, while working just fine on PC - we'll fix it.
     
  15. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Thanks ;)
    Do you have an idea of the timeframe for the fix on mobile ?
     
  16. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,673
    Could you report a bug with your simple repro attached?
     
  17. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Got it !
    To "force" the resolution we need to call again SetResolution after a short delay...

    Here is a working exemple :
    Code (CSharp):
    1.  
    2. public class ResolutionChanger : MonoBehaviour
    3. {
    4.     void Start()
    5.     {
    6.         Debug.Log("!initial Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height);
    7.         StartCoroutine(changeRes(1280,720));
    8.     }
    9.  
    10.     IEnumerator changeRes(int w,int h)
    11.     {
    12.         yield return new WaitForSeconds(1.0f);
    13.         Debug.Log("Current Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height);
    14.         Screen.SetResolution(w, h, true);
    15.         yield return new WaitForSeconds(0.1f);
    16.         Screen.SetResolution(w, h, true);
    17.         Debug.Log("New Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height);
    18.     }
    19.  
    20.     void OnGUI()
    21.     {
    22.         int w = Screen.width, h = Screen.height;
    23.         GUIStyle style = new GUIStyle();
    24.  
    25.         Rect rect = new Rect(0, 0, w, h * 2 / 100);
    26.         style.alignment = TextAnchor.UpperLeft;
    27.         style.fontSize = h * 2 / 100;
    28.         style.normal.textColor = Color.white;
    29.         string text = "Resolution : " + Screen.currentResolution.width + "x" + Screen.currentResolution.height ;
    30.         GUI.Label(rect, text, style);
    31.     }
    32. }
    Repro case + workaround sent to the debug team.
     
  18. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Ouch... this trick work only in the repro/new project... not in our game one :confused:... Don't know why...
    The only difference is this output line "Application is already in fullscreen, won't resize window, only changing resolution to 1280 x 720." when working (after the second SetResolution call)
     
  19. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,673
    Blind guess, but maybe because of:
    Code (csharp):
    1.  
    2. QualitySettings.antiAliasing=0;
    3.  
    which also implicitly affects D3D swapchain.
     
  20. Namal

    Namal

    Joined:
    Jul 6, 2012
    Posts:
    15
    Tried it but no changes ...

    Edit : I found the way to change the resolution also in the game project (using the previous ResolutionChanger.cs script). I had to clean all files / folders except Asset and ProjectSettings; reopen the project (so Unity reimport all files), reswitch to Windows Store - Universal 10 build.
    So, it seems like some old/broken code was still present in some temporaty folder...
     
    Last edited: Feb 25, 2016
  21. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,673
    So you have this resolved now?
     
  22. BScrk

    BScrk

    Joined:
    Aug 12, 2014
    Posts:
    6
    Yes Tomas, we "solved" the problem cleaning the game project (removing all except Asset & ProjectSettings folder) and using the ResolutionChanger.cs script trick (double delayed call of SetResolution function).
    So for now is a "quite acceptable" workaround.
    QA said they are able to reproduce this bug and have sent it for resolution a the dev team.
     
  23. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    Yup, we got it.
     
  24. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    What's the state of this issue?
    Could it be that the bug is still valid for Universal Windows 8.1 phone projects?
    Using Unity 5.3.7
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    It's been fixed in 5.3.4p3 back in April. Are you still able to reproduce something like that?
     
  26. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Something like that at least, yes.
    Win 10 phones work fine it seems, Win 8.1 phones trouble me.
    I will try to see if I can make a repro project.