Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by hubatish · Jul 25, 2015 at 11:23 PM · documentationexecution order

Incorrect Unity Execution Order for OnApplicationQuit?

I'm aware of this doc that tells the execution order of Unity events:

http://docs.unity3d.com/Manual/ExecutionOrder.html

There's also a beautiful chart: alt text

However, recently I put Debug.Log messages in OnDisable and OnApplicationQuit, and it seems like OnApplicationQuit is actually called first, contrary to what the chart shows. Is this just my copy of Unity, or does everyone else get the same thing?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hubatish · Jul 25, 2015 at 07:02 PM 0
Share

If someone can try it quickly, here's a script:

     using UnityEngine;
     using System.Collections;
     
     public class ScriptOrder : $$anonymous$$onoBehaviour {
     
         protected void Awake()
         {
             Debug.Log("Awake");
         }
     
         protected void OnEnable()
         {
             Debug.Log("OnEnable");
         }
     
         // Use this for initialization
         protected void Start () {
             Debug.Log("Start");
         }
     
     
         protected void OnApplicationPause()
         {
             Debug.Log("OnAppPause");
         }
         
         protected void OnDisable()
         {
             Debug.Log("OnDisable");
         }
     
         protected void OnApplicationQuit()
         {
             Debug.Log("OnAppQuit");
         }
     
         protected void OnDestroy()
         {
             Debug.Log("OnDestroy");
         }
     
     }


avatar image Alec-Slayden · Jul 26, 2015 at 12:28 AM 0
Share

I have noticed this too. I wouldn't $$anonymous$$d an official word on it

avatar image Bunny83 · Jul 26, 2015 at 12:36 AM 0
Share

@alec-slayden: "an official word"? UnityAnswers is not a place for that ^^. Either consult the Forums or if you think the documentation is wrong / misleading file a bug report in Unity.

avatar image Alec-Slayden · Jul 26, 2015 at 01:28 AM 0
Share

fine, "concrete answer", then :p

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Bunny83 · Jul 26, 2015 at 12:33 AM

Of course OnApplicationQuit is executed before OnDisable and OnDestroy since it's

Sent to all game objects before the application is quit

If Unity would destroy the objects before sending OnApplicationQuit there would be no gameobject that could receive that message.

The final OnDisable (as well as OnDestroy) will be invoked as a result of destroying the object when the application quits. Also note there are no arrows within the "decommissioning" section.

The chart might be a bit misleading. Since a lot of these messages can be invoked in different cases, that chart can never cover all situations at once. If it would there would be arrows and lines all over the place. That chart mainly shows the mainloop and everything related to that.

For example "OnEnable" is positioned before "Start". However if a Gameobject was already "started", got disabled and is enabled again OnEnable will be called again but Start won't. Another thing is the way the physics step is described. It doesn't cover the case when a physics step is skipped. In that case the update loop should bypass the whole physics block. In a real flowchart all conditional events (OnCollisionXXX, OnMouseXXX, OnBecameVisible, ...) would need a bypass as well.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Physic Material Friction Combine Mode lack of documentation? 2 Answers

Generating (HTML) documentation for Unity Script (not C#) ? (like Doxygen) 1 Answer

Networking Destroy Player's RPC function uhm WHAT? 1 Answer

uGUI API Documentation 2 Answers

Collision.impulse 2D equivalent 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges