x


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.

more ▼

asked Jul 19 '12 at 04:10 PM

Caiuse gravatar image

Caiuse
787 83 102 121

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.
   }
}
more ▼

answered Aug 08 '12 at 05:45 PM

Novack gravatar image

Novack
96 3 4

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.

5 hours ago Fattie
(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:

x1953
x4
x1

asked: Jul 19 '12 at 04:10 PM

Seen: 1801 times

Last Updated: 5 hours ago