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. Dismiss Notice

Linux Build problems with Dual Monitor

Discussion in 'Editor & General Support' started by sevensails, Feb 22, 2015.

  1. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Hi!

    I have a Dual Monitor Config on Ubuntu (Each one with resolution 1920x1080).

    Screen.currentResolution works ok for all developments platforms but Linux. Instead of returning 1920x1080 it returns me (3480x1080). It sums the two monitor resolutions.

    How to fix it? There is some workaround to return only the resolution of the Main Monitor?

    Thanks!
     
  2. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Any advice?
     
  3. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Same issue here with the latest Unity v4.6.7f1 and Ubuntu 15.04 . The highest resolution option includes the width of both monitors, and if I choose it, I also get the mouse pointer offset incorrectly from where it actually is. Changing to a single-monitor resolution works OK.

    Did you ever sort out a workaround for this Wagenheimer?
     
    LeonH likes this.
  4. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Code (csharp):
    1.  
    2.         RunningResolution = Screen.currentResolution;
    3.  
    4. #if UNITY_STANDALONE_LINUX
    5.         Resolution[] resolutions = Screen.resolutions;
    6.         Debug.Log("Available Resolutions");
    7.         foreach (Resolution res in resolutions)
    8.         {
    9.             Debug.Log(res.width + "x" + res.height);
    10.             RunningResolution = res;
    11.         }
    12.  
    13.        
    14. #endif
    15.  
    Getting the last value from Screen.resolutions seems to return the correct resolution.
     
  5. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Thanks or your response! Unfortunately that doesn't work either for my setup. Screen.currentResolution (starting in windowed mode, since it gives the native res that way on Win/Mac) returns 3200x1200, and the highest Screen.resolutions returns 1920x1200. My actual screens are 1600x1200, which is the second-highest entry in Screen.resoutions.

    Quite possibly more of a Linux bug than a Unity bug, but still a problem.

    I think what I might do is just have the game start in a window of reasonable size on Linux instead of trying to start at fullscreen native res. The in-game dropdown to change resolution will still include the erroneous last entry, but at least if they select that manually themselves they'll know what they did to revert it. Better than starting the game for the first time and it's already broken.
     
    Last edited: Sep 15, 2015
  6. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Do you know how to report a bug do Unity? This is a old problem and I think Unity Team should be able to fix it.
     
  7. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Yeah, I'm still on Unity 4 though, so it may be fixed in Unity 5.
     
  8. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
  9. Tak

    Tak

    Unity Technologies

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Returning the full desktop resolution is the intended, documented behavior for Screen.currentResolution.

    The correct way to start a player in fullscreen at the native monitor resolution is to select "Default is Fullscreen" and "Default is Native Resolution" in the player build settings.
     
  10. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Hey thank you Tak, I never even saw that because I started this project before it was introduced and with Default Is Full Screen unticked, it doesn't show up! That will help my initial startup sequence and I can probably use that value to limit the Screen.resolutions results as needed as well.

    There is still some strangeness with the Screen.resolutions results and what happens when you select the multi-monitor ones, but at least I should be able to work around that now.
     
  11. Tak

    Tak

    Unity Technologies

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Yes - when setting, we clamp the resolution to what's available on the display, but I have an open bug about some of the internal tracking stuff not getting similarly clamped when a user explicitly sets a too-large resolution (particularly if we're already running in fullscreen mode).
     
  12. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Unfortunately this didn't work as I hoped. I was hoping that starting with "Default is Fullscreen" and "Default is Native Resolution" would return the resolution of the main monitor only, but it still returns the resolution of both (actually more than both - it's still not picking up that one monitor is rotated to portrait orientation in the OS).

    Is there any way to get the native resolution of just the main monitor on Linux?
     
    sevensails likes this.