- Home /
Is there a way to force the unity player to minimize?
Such as, for when I want to launch an external web page based on users having clicked some button, and the game should be temporarily minimized until the user wanting to come back to the application?
Answer by qJake · Jul 06, 2010 at 06:25 PM
Ordinarily, if you just call the default browser, it should pop up over your game, "minimizing it". Something like this should do the trick:
System.Diagnostics.Process.Start("http://google.com/");
Note that this doesn't work in the web player.
Other than that, you would have to write a C++ plugin that hooked into the actual application window so you could send a Minimize message, and I don't know if Unity exposes the Win32 application environment to plugins or not.
Sure enough, in testing it does that automatically already. Problem solved!
Answer by liuww · Dec 10, 2012 at 07:50 AM
I allways use this.
import System;
import System.Runtime.InteropServices;
@DllImportAttribute("user32.dll")
public static function ShowWindow(hwnd:IntPtr,nCmdShow:int):boolean{};
@DllImportAttribute("user32.dll")
public static function GetForegroundWindow ():IntPtr{};
@DllImportAttribute("user32.dll")
public static function GetActiveWindow ():IntPtr{};
function OnGUI () {
if(GUI.Button(Rect(100,200,100,50),"Minimize")){
//Minimize the window
ShowWindow(GetActiveWindow(),2);
}
}
Hi there, unfortunately the DllImport is not recognized by my $$anonymous$$onoDevelop. Can you imagine why? Thanks!
2017 and it works perfectly right away. Thank you for this answer!
Am I correct to assume this won't work for a $$anonymous$$ac?
Yes you are correct @$$anonymous$$tiveType
Your answer
![](https://koobas.hobune.stream/wayback/20220613064000im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Problem with webplayer and occlusion culling 0 Answers
How to remove a dotted line around the WebPlayer 4 Answers
how do you show stats in webplayer? 1 Answer
Can people access my game assets through the webplayer? 3 Answers