- Home /
Detecting when applicationDidBecomeActive In Unity
We are trying to detect when the app becomes active again after being in background mode, we want to be able to fire a method when this occurs. It's such a simple idea there is even a MonoBehavour method OnApplicationPause which can be used as the app enters background mode, but non for OnApplicationResume.
Any ideas, Cheers.
Answer by Novack · Aug 08, 2012 at 05:45 PM
Guys, it is my understanding that OnApplicationPause() gets called on going background, and again on going back to foreground. To know which case it is, you simply analize the argument passed to the function:
function OnApplicationPause (pause : boolean)
{
if(pause)
{
// we are in background
}
else
{
// we are in foreground again.
}
}
I understand the same. Docs - http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.OnApplicationPause.html
possibly a gotchya here is that this must, of course, be on a dontdestroyonload object .. something that is persistent throughout your game. maybe thats what caught up the OP.