Maximized Windows by default

Hi,

I am making an application for Standalone Windows. Is there anyway to have a maximised windows screen by default? If I do full screen, the Application Title bar just disappear. I want to keep that bar, but maximised windows when start.

Here is my settings:
Fullscreen Mode : Maximized Window
Default is Native Resolution: True
Resizable Window: True

I also tried in script:

Screen.SetResolution(Screen.width, Screen.height, FullScreenMode.Windowed, 30);

but this doesn’t maximised my window by default. Is there any way to work around it?

You probably want to use FullscreenMode.MaximizedWindow in your script. However, I tried that and it still didn’t work. This seems like a bug to me. You should report it to Unity.

Sam

Have you figured out a workaround. I’m also facing this issue. Standalone player launches with a gap above the top of the screen and a little between the left of the screen. Clicking the maximize button fills in these gaps, but then it launches this way again next time

Bump

Edit: I’ve scoured the internet trying to find a built-in solution for Unity but it seems like there isn’t support to Maximze the window via script. However I found a quick work-around to forcing the game window to maximize using windows dll scripts:

public class Settings : MonoBehaviour {
    [DllImport("user32.dll")]
    private static extern IntPtr GetActiveWindow();
    [DllImport("user32.dll")]
    public static extern bool ShowWindowAsync(int hWnd, int nCmdShow);

    void Awake() {
        if (!Screen.fullScreen && !Application.isEditor) // auto maximize window
            ShowWindowAsync(GetActiveWindow().ToInt32(), 3);
    }
}

This forces the window to maximize on start.

Heres an enumeration containing all the possible window states (3 being what I used above):

public enum  WindowState : int {
    Hide = 0,
    ShowNormal = 1,
    ShowMinimized = 2,
    ShowMaximized = 3,
    NoActive = 4,
    Show = 5,
    Minimize = 6,
    ShowInNoActive = 7,
    ShowNA = 8,
    Restore = 9,
    ShowDefault = 10
}
1 Like