x


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.

more ▼

asked Nov 04 '10 at 05:04 PM

Aldo Filippini gravatar image

Aldo Filippini
16 1 1 1

"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.

Jun 12 '12 at 10:54 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jun 12 '12 at 10:38 AM

keld-oelykke gravatar image

keld-oelykke
346 1 2 5

Just want to add that GetWindowRect and GetClientRect is not part of .NET / Mono. It's a native code function (in the User32.dll) of windows. If you are on Mac 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# ;)

Jun 12 '12 at 10:50 AM Bunny83

Good point Bunny!

Jun 12 '12 at 11:21 AM keld-oelykke
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 08 '11 at 08:18 PM

green_core gravatar image

green_core
91 2

(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:

x200
x11

asked: Nov 04 '10 at 05:04 PM

Seen: 1810 times

Last Updated: Jun 12 '12 at 11:21 AM