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

Display and Screen Class

Discussion in 'Editor & General Support' started by BentiGorlich, Aug 16, 2021.

  1. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    Hello Everyone,

    I have a problem with the
    Code (CSharp):
    1. Display.displays
    and
    Code (CSharp):
    1. Screen.resoltions
    Methods.

    I am populating dropdowns with the options that these methods provide. That is working well when in the editor, but if I built the game I don't get any displays and only one resolution.

    Does anyone have any idea why?

    Thanks in advance
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Googling for those two ultra-common class names is going to be completely useless.

    Instead, Google around for questions about "Unity not finding other displays" and "Unity not reporting all resolutions" and stuff like that. It's a pretty common issue and there's lots of things to check.
     
  3. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Multiple-display video card driver software is the second-flakiest software on the entire planet.

    It is surpassed in flakiness only by HP all-in-one inkjet printer driver software.

    Good luck.
     
  5. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    Well that is not what I am trying to achieve. I just want to give players the option to choose their output display.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    Display class allows you to spawn multiple windows with content in them. It does not allow you to move your main game window to a different display. There's a whole thread on it: https://forum.unity.com/threads/switch-monitor-at-runtime.501336/

    As for Screen.resolutions being empty in a built game: I've only seen that happen when running the game through remote desktop. Are you doing anything of the sorts?
     
  7. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    no I am running it on my local computer.
    Ok thanks for that, I am gonna try it
     
  8. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    Ok I have a guess to why the screen resolutions may be wrong. I am applying my user settings at the start of the game. These Usersettings consist of fullscreen mode and resolution, as well as other settings.
    Am I supposed to change the "playerPrefs" mentioned in the forum thread you linked? And if yes, how would I do that?
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    No, you don't need to touch player prefs. Doing that is unsupported.

    What exactly does Screen.resolutions return, and how do you print it out?
     
  10. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    Ok, so I solved my problem. Due to the refresh rate parameter, each resolution had multiple entries which threw an error.
    So this is solved.

    So how do I move the fullscreen window to another monitor? There was no clear solution in the thread you linked (at least for me)
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    If you're on Unity 2020 or earlier, you'll have to P/Invoke into Windows MoveWindow API. In Unity 2021.2 we added a new method to the Screen class "MoveMainWindowTo" which allows you to do it without calling Windows APIs directly.
     
  12. BentiGorlich

    BentiGorlich

    Joined:
    Jun 30, 2021
    Posts:
    21
    Ok, than I put a hold on that and just wait until 2021 is smooth enough for me to upgrade my project to it.

    Thank you so much for your help, I really appreciate it :)