Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

OnApplicationPause Execution Order incorrect

Discussion in 'Documentation' started by feiting, Feb 18, 2016.

  1. feiting

    feiting

    Joined:
    Oct 26, 2012
    Posts:
    33
    OnApplicationPause is called before Start() in our app, or rather, at any given time. The flow diagram isn't correct. Also, is there a function to guarantee initialization before anything else? I have logCats verifying this, but it's also documented on forums.

    02-18 11:49:12.077: I/Unity(10020): Pause Called in class
    02-18 11:49:12.102: I/Unity(10020): Start Called in class

    This is a cellular tablet, S2. Unsure why this happens, but I have no initializer and have to create a gate, extra set of logic (though simple), similar to UIView's on iPhone. (Same issue)

    Posted here because the documentation is misleading, Pause() has nothing to do with flow of when called.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    OnApplicationPause(bool isPaused) receives a parameter that states whether this is a pause or not:
    Code (CSharp):
    1. void OnApplicationPause(bool isPaused)
    2. {
    3.     if (isPaused)
    4.     {
    5.         // pause
    6.     }
    7.     else
    8.     {
    9.         // resume
    10.     }
    11. }
    The call you're probably seeing is the one for "resume", which also gets called when the game starts.
     
  3. feiting

    feiting

    Joined:
    Oct 26, 2012
    Posts:
    33
    Oh yes, that was obvious 'cause the boolean is flipped, but that wasn't the issue I was reporting. The documentation simply says it happens in a certain order.