Unity Community


Results 1 to 5 of 5

  1. Posts
    15

    Call function when coming back from background?

    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. Location
    Sacramento CA, USA
    Posts
    1,597
    http://unity3d.com/support/documenta...tionPause.html

    It sends a bool telling you if it's entering foreground/background.


  3. Posts
    15
    Quote Originally Posted by Daniel View Post
    http://unity3d.com/support/documenta...tionPause.html

    It sends a bool telling you if it's entering foreground/background.
    New to this part of Unity... So where/what does is say foreground/background?

    function OnApplicationPause (pause : boolean) : void


  4. Posts
    15
    I have tried this:
    Code:  
    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. Location
    Sacramento CA, USA
    Posts
    1,597
    Code:  
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •