Forum rules - please read before posting.

Prevent window resizing and fullscreen mode of desktop builds (win, mac, linux)?

edited August 2015 in Technical Q&A
Hi there!

I have an important question. My games are made for a specific resolution (960x600) and they shouldn't be played in fullscreen mode because this totally breaks the UI and destroyes the (faked) pixel-perfect look. I'd like to have it like in AGS, where it's simply not possible to switch to fullscreen mode when you're running windowed mode.

Unfortunately, there are no "prevent fullscreen" functions out of the box in unity. Although the "Maximise" buttons at the right upper corner of the client's game window are disabled, "Alt + Enter" (windows) and "Command + F" (mac) switch to fullscreen. In linux the game window can resized at will which is really bad. 

As a quick and dirty solution I call a custom action list containing "Screen.SetResolution (960, 600, false);" at the beginning of the game, at every scene start and when the pause menu is opened, so the player isn't locked forever in an ugly fullscreen window.

I also tried to check the resolution at every update and resize it if the resolution has changed, but this only worked on windows 7 and newer versions of windows. On mac, the screen constantly flickers and had other strange effects (drag and drop of icons wasn't possible anymore). Linux just ignored the "Screen.SetResolution" but it extremely flickers and makes the game unplayable. 

Does anybody know how to tame window resizing on Linux and the fullscreen on all platforms? I don't think I'm the only Unity and AC user who has this kind of problems, am I?

Thank you very much!

Cheers,
Christian
«1

Comments

  • Not to be a dick or anything, but I think you might be fighting a losing battle. In this day and age, people using desktop systems expect to be able to use whatever resolution and windowed/fullscreen setting they please, and I personally HATE anything that doesn't deal smoothly with scaling and different aspect ratios.

    I get your point about the pixel perfect look, but I really think you should focus your efforts on finding a technical solution to make it scalable to an acceptable standard instead.

    Sorry, not much of a contribution to your problem - I'll shut up and get back to coding!
  • Thanks, no problem :)
  • My main problem is the heavy flickering on WinXP, Mac and Linux which occurs as soon the update function is checking the resolution. On Win7+ platforms the problem is solved, because even in fullscreen mode the original 960x600 resolution is perfectly upscaled. But I want my games to function the same on all platforms. This is the script I'm using.

    Any ideas why the weird update function flickering is happening on those platforms? Thanks!
  • edited August 2015
    Here's a screenshot of what "can't restrict windows resizing" means on linux:
    (left original resolution, right freely resized window)
    image
  • edited August 2015
    I thought all these options were in the build settings :o

    enable full screen. display resolution dialogue etc.

    Not sure about resize window tho. althoguh im sure i;ve come across code that disables the window (might have been linux thing)
  • edited August 2015
    In the build/player settings, you can only uncheck "resizable window", but the fullscreen function (alt+enter, cmd+f) can still be used on win and mac. linux completely ignores "resizable window". A "disable fullscreen" option is completely missing from Unity's "Standalone Player Options". Sigh.
  • Do really get screen flickering just checking the screen resolution from Update()???

  • It seems so on WinXP, Mac and Linux. As soon the script containing the update() is disabled, flickering stops.
  • Weird ... I'll be doing some test builds of my own project for Linux this weekend, so will check if I see the same behaviour.

    Will test on Mac if I can get hold of the guy who borrowed my tired old MacBook some time ago - thanks for reminding me to get it back! :-)
  • you're welcome :) I'm really curious if you'll run into the same issues, and I'd be extremely thankful for every tip on how to fix this issues :)
  • Just did a quick test on Linux - no flickering.

    Will try extending it to force a specific window size tomorrow - you managed to arouse my interest after all!  :-)
  • edited August 2015
    Obviously I couldn't just leave it until tomorrow - why go out and have a few beers and be social on a Friday night when you can stay in and fool around with Unity and Linux???  :-)

    Anyway, forcing it to switch back to the desired window size from Update works fine for me - as long as the window is not maximized, in which case I also experience flickering. Looks like the window manager and Unity are fighting each other for control of the window size.

    But at least it handles the "freely resized window" example shown in your screenshot gracefully.

    EDIT: Except it does flicker a bit during the actual resizing as you're dragging the edge of the window.
  • Interesting, cool! Would you mind sharing your script after your research is finished? :)
  • It's actually exceedingly simple:

    void Update () {
    if (Screen.height != 600 || Screen.width != 960 || Screen.fullScreen) {
    Screen.SetResolution(960, 600, false);
    }
    }

    ... in a script added to an empty GameObject in the scene.
  • edited August 2015
    Also deals with Alt+Enter on Windows, though you might have to Alt+Tab to get the mouse cursor back afterwards.

    It's very unfortunate that Ubuntu's graphical shell is also called Unity when you're googling for a solution for this ...  :-/
  • Unity 5.2 is out! I will get it asap and try out the linux improvements :)
  • Damn ...

    So that should really be: "Fix attempted in 5.2.0". ;-)


  • Apart from that, 5.2.0 seems to do light building faster - and native support for Visual Studio is very good news for me. I'm not going to miss MonoDevelop!!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.