1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. Unity 5.6 is now released.
    Dismiss Notice
  3. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  4. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  5. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Call function when coming back from background?

Discussion in 'iOS and tvOS' started by jmansa, Apr 13, 2012.

  1. jmansa

    jmansa

    Joined:
    Apr 13, 2012
    Posts:
    40
    I'm trying to figure out how to call a function when my iOS application is coming back from background. I have read through som posts I can use "OnApplicationPause" but not sure how to do so when coming back from background... Can anybody help?

    Thanks in advance :)
     
  2. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,320
  3. jmansa

    jmansa

    Joined:
    Apr 13, 2012
    Posts:
    40
  4. jmansa

    jmansa

    Joined:
    Apr 13, 2012
    Posts:
    40
    I have tried this:
    Code (csharp):
    1. function OnApplicationPause(pause:boolean){
    2.    game_message = true;
    3. }
    That works when the application goes into sleep... But I want to run the game_message = true; when the application wakes up again! How do I do this?

    Hooping for help :)
     
  5. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,320
    Code (csharp):
    1. function OnApplicationPause (pause : boolean) {
    2.    if (pause) {
    3.       // Put code in here that you want to run when the game enters background.
    4.    }
    5.    else {
    6.       // Put code in here that you want to run when the game enters foreground.
    7.    }
    8. }
    I would also try OnApplicationFocus.