|
Hey all, I was just trying to figure out how we can detect when a user has minimized the application (say, via alt+tab). Here's what I'm trying to do. When the user minimizes the game, I'd like it to automatically pull up the escape menu I've created. I don't want the game to pause, I just want the escape menu to open. Is there a certain command that determines when the user has taken focus off of the game? btw - This can be answered for Javascript or C#, either or both would be awesome! Thanks,
(comments are locked)
|
|
what if you create a screen-wide transparent gui element and use OnMouseExit to pull up your escape menu. http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseExit.html
(comments are locked)
|

There is no function to determine this, since that's strictly a Windows problem (Something similar exists on Mac, but it's a little different, and you can never "minimize" a webplayer game). You would need to write a C++ plugin (Which requires Unity Pro) in order to detect when the application window has lost focus (either through alt+tab or some other means).
It's not a web-player game, it's a stand-alone application. Unity has a built in function that when focus is taken off the game it automatically pauses it or leaves it running if I wish, I was hoping I could simply alter this function to do as i wish above.
See: http://unity3d.com/support/documentation/ScriptReference/Application-runInBackground.html
Yes, I know about that function, but you can't access how it determines if the game is in the background or not, nor can you just... change what it does (APIs don't work like that). Like I said, you need to write a C++ plugin if you want to determine when your game has lost focus or not.
Maybe there are differences what functions (Events, Updates, ...) are called in the last frame the application has focus? Maybe coroutines aren't paused the same way as the normal execution loop? Here is the calling order: http://forum.unity3d.com/viewtopic.php?t=2719 ... Just some thoughts, I haven't tried it out.
I'm wondering if I can manipulate the auto-mated pause to try and get the game to detect when it's been paused, and have it un-pause and open the desired menu instead. I'll fiddle with this myself and if either solution is plausible, I'll post my findings.