x


Lock Resolution

Is it possible to lock a game at a set resolution and prevent the user from resizing the window or switching fullscreen? Fullscreen wouldn't be a problem except that if you switch to fullscreen and back, Mac OS X retains the monitor's native resolution in the new window size regardless of its size prior to fullscreen.

Another solution might be to allow fullscreen, but return the window to the preferred size on minimizingthis would require an onFullscreen() callback (or something like it).

Much help would be appreciated!

more ▼

asked Dec 02 '10 at 05:05 AM

gmerriment gravatar image

gmerriment
13 2 2 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Screen.fullScreen is a bool property that can be read or set. You can use this to determine if the player has just left fullscreen and switch to a different resolution.

example:

private var wasFullScreen : Boolean = false;

function Update () {
    if (wasFullScreen && !Screen.fullScreen) {
        // this gets executed once right after leaving full screen
    }
    if (!wasFullScreen && Screen.fullScreen) {
        // this gets executed once right after entering full screen
    }
    wasFullScreen = Screen.fullScreen;
}

edit:

If you're building for the web player you can disable the right click menu so people can't go fullscreen to begin with.

To get to the setting go to File > Build Settings, then choose Player Settings and select No Context Menu for the Web Player Template.

alt text

more ▼

answered Dec 02 '10 at 05:14 AM

Rennat gravatar image

Rennat
664 5 8 18

Excellent, I wondered if it could be used that way. Thank you!

Dec 02 '10 at 05:49 AM gmerriment

Ideally, it would be better if I could completely disable fullscreen and resolution changes, but this serves as a workable substitute.

Dec 02 '10 at 06:12 AM gmerriment

well you could test for fullscreen every frame and set it to false if if ever goes fullscreen :D or if you're using a web player there is a setting to hide the context (right click) menu so there is no option to go fullscreen.

Dec 02 '10 at 06:38 AM Rennat

That's what I ended up doingit does prevent fullscreen, but there is an unfortunate momentary "blink". And it is counter-intuitive: having the option implies that the user can do it, and preventing its execution is more frustrating than not giving the user the option. Maybe an item for the Unity wish list...

Dec 03 '10 at 04:31 AM gmerriment
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x378
x84

asked: Dec 02 '10 at 05:05 AM

Seen: 1517 times

Last Updated: Dec 02 '10 at 05:05 AM