- Home /
Block or Override Alt-Enter Fullscreen
The project I'm currently working on runs at a fixed screen size of 800x600 and is deployed as a windows standalone. At that resolution though, when you switch to full screen on most monitors the image will stretch to whatever aspect ratio your monitor is. It's ugly and not ideal, and given the project changing aspect ratio or using a more flexible base resolution won't work.
The proper solution that I'm trying to figure out is to have a different full screen resolution from the windowed resolution, so I can pick a good resolution matching the aspect ratio. Optimally I'd just use the current desktop resolution (the project is simple enough that this is unlikely a performance issue). It should be simple to do using Screen.SetResolution, if it weren't for one issue: Unity handles alt-enter internally to automatically and toggles to full screen with the currently used resolution.
As best I've looked, I can't find a way to override this default behavior. You can't stop it, and you can't turn it off. The best solution I have so far is quite ugly too. When in fullscreen it checks if you're at 800x600 and then switching to a more favorable resolution. It results in multiple resolution changes, which on some displays can take 10-15 seconds, and it messes with the position any other applications you have open.
Is there any easy way to just disable the default alt-enter functionality? If I could just handle the shortcut myself it would be perfect.
tl;dr: I want the game to have a different windowed resolution from fullscreen resolution, ideally by handling alt-enter clicks myself rather than by the unity engine.
I don't think there is any way to disable it from Unity. Alt-Enter is a Windows shortcut, and Unity doesn't really have any authority there...
That's not true at all is it? Alt-enter is handled by the application, if it's not coded to handle it, it won't handle it. It's the go-to key combination for switching between windowed and full screen, but it isn't a windows shortcut.
Yes, you're probably right... I was thinking Alt-Tab. Interestingly enough, my computer crashed when I switched a Unity game to full-screen mode. $$anonymous$$aybe because I have two monitors?
Answer by Achab · Apr 28, 2017 at 06:02 AM
Little update.
Unity have added the flag "Allow Fullscreen Switch" in Project Settings\Player\Resolution and Presentation. Works perfectly.
This was a really old question, but it is a welcome answer none the less!
Answer by Radetic · Jul 24, 2015 at 02:43 PM
Any answers for this question yet? I'm currently working on a project that is not supposed to go fullscreen by software requirements and the ALT+ENTER shortcut is really getting in the way.
Thanks in advance for any help provided
Answer by Eric5h5 · Sep 29, 2013 at 09:40 PM
function Update () {
if (Screen.fullScreen) {
Screen.fullScreen = false;
}
}
Thanks for the reply, that will effectively prevent fullscreen mode (through the rather roundabout way of waiting for the game to switch to full screen, and then switching back), but what I'm looking for is to have a different full screen resolution from desktop resolution, or being able to handle alt-enter usage myself.
Answer by googler · Nov 13, 2013 at 08:00 AM
Same problem on Mac. I believe that you can do it only through the plugins and native libraries.