- Home /
Windows maximized
Is it possible to start an app (standalone PC Unity app) with a maximized window? The default resolution I put int the player is not exactly what I'm looking for: a window that expands in the whole available desktop working area (1 monitor) without interfering with the windows task bar.
"the whole available desktop working area" usually refers to the whole desktop, but what do you mean by "1 monitor"? Do you mean you have two monitors but want to display it on just one, or do you mean you only have one monitor at all? If you have two monitors, the whole desktop will cover both monitors and not just one.
Answer by keld-oelykke · Jun 12, 2012 at 10:38 AM
If you want to maximize your standalone unity app running in Window Mode, you can do so by using Screen.currentResolution to get the current desktop resolution.
You can then use SetResolution with the desktop resolution, BUT you need to reduce the arguments width and height to give room for the Window borders.
My guess is that SetResolution was designed for fullscreen and it doesn't really do the job for when you need to change the Window size in Window Mode. SetResolution changes the client area e.g. rendered viewport within the Window. It seems that if SetResolution results in a window greater than the desktop resolution then Unity shrinks the window.
The workaround is to take your desired window size and subtract it with the current window border size.
In C# you can use the native method calls GetWindowRect and GetClientRect to calculate the border sizes.
Just want to add that GetWindowRect and GetClientRect is not part of .NET / $$anonymous$$ono. It's a native code function (in the User32.dll) of windows. If you are on $$anonymous$$ac or any other platform you need to find something equivalent.
Btw. You can use those function in any language in Unity. Both UnityScript and C# are compiled to CIL. There are some language features (like properties, interfaces) that can only be defined in C#, but external functions / interfaces can be used by all languages.
I still prefer C# ;)
Answer by green_core · Dec 08, 2011 at 08:18 PM
It looks like fullscreen mode. To run unity in window mode you can change player settings in Edit->Project Settings->Player and set "Default Is Full Screen" property to false. Also you can change it programmatically by using Screen class.
"$$anonymous$$aximized window" is not the same as "Fullscreen".
Answer by kevin-masson · Jul 31, 2020 at 01:30 PM
It is possible, but not natively with Unity.
Here is a script that maximize your game window on startup. It only works on Windows and you just need to place the script in your project. You need to replace "APP_NAME" by a regex that matches your Application.productName
.
Use these settings for your player settings:
Your answer
Follow this Question
Related Questions
Minimizing and maximizing by script 3 Answers
Keeping MonoDevelop from going fullscreen when opening a file 0 Answers
Maximize Editor Game Window on Mac 1 Answer
Customize Game Window (For Exported Project) 1 Answer
Maximizing Unity Freeze 0 Answers