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.
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.
I double checked and for the resolution part I didn’t find anything useful (only this: Screen.resolutions shows only 640x800 but that is not the case I am having)
And for the display part I didn’t find anything at all.
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: Switch Monitor at runtime
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?
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?
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.
I was able to get MoveMainWindowTo() to work, however, it exhibits the same behavior - it switches to the correct monitor, but snaps back immediately. Would you happen to know why or what I can change to fix that?