|
In a standalone player, is it possible to force minimizing the screen by scripting? What I am trying to do is minimizing the screen when some event happens, and then maximising the screen whe I read a value from a text file. Maybe i have to write a plugin, in that case how does it work? Thanks
(comments are locked)
|
|
You can do anything with window by using WinAPI. But you have to get window handle to do it. In usual .NET application you can get them by this way:
But it doesn't work in unity. So, i use another way to get the handle. I enumerate all windows by function To minimize window you can use To use WinAPI functions you have to import them: Hi green_core. I have tried your method and when I find the matching process id to Process.GetCurrentProcess().Id the hWnd does not seem to be the window. Is there something I am doing wrong here.
Jun 05 at 10:58 AM
Sabretoothy
Your callback, which is EnumWindowsProc, is called for each window. As a parameter of function you receive hWnd, which is a handle of window. You should get process id of this window by GetWindowThreadProcessId function. To put hWnd into the function you should wrap it into HandleRef. You can do it like this: var obj = new object(); var hRef = new HandleRef(obj, hWnd); So. After this put it into GetWindowThreadProcessId and compare result with your ProcessId. If they equal - bingo! :) You've just found your window. Then return false to interrupt the enumeration of windows. If they don't equal, you should return true to continue enumeration. I hope it would be helpful for you.
Jun 05 at 12:42 PM
green_core
That sorted it thank you. I was missing the step of returning false to interup the enumeration after I had found the matching Process ID.
Jun 05 at 03:05 PM
Sabretoothy
(comments are locked)
|
|
http://unity3d.com/support/documentation/ScriptReference/Screen.SetResolution.html Switch that boolean argument to True for fullscreen and False for windowed. And the width and height arguments to resize the window of course...
Dec 08 '11 at 07:52 PM
cj_coimbra
(comments are locked)
|

also unanswered (no good ones at least): http://answers.unity3d.com/questions/25136/can-i-do-this-in-unity-make-maximise-button.html