Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Suyuanhan · Aug 04, 2011 at 08:22 AM · functionmonobehavioursequenceexecution

Execution sequence of functions?

I want to know when the unity3d application run,

Which functions execute first,and next and so on?For exmaple a script include:

Awake(), Start(), Update(), OnTriggerEnter(),OnMouseOver, and other MonoBehaviour's functions

As I know,the simple sequence is: Awake() --> Start() --> Update()

but I want to know the others funtions' sequence of execution.Like OnMouseOver() and Update(),which first?

Although I can Debug them ,but I want to know how they execute?

And what's more: Different Ojbects add the same component ,Which component's functions execute first? According to What?

Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · Aug 04, 2011 at 09:31 AM

http://answers.unity3d.com/questions/topics/execution-order.html

http://unity3d.com/support/documentation/Manual/Execution%20Order.html

http://www.unifycommunity.com/wiki/index.php?title=Event_Execution_Order

I guess you've already read those? Because you can get that information any clearer. You can test it yourself by putting a Debug.Log with a timestamp into each function if you want.

GameObjects are processed in the order they are stored inside the engine. You can't change the order from outside.

The only events that can be ordered are OnGUI with GUI.depth and the rendering of cameras with Camera.depth.

If you need a special order of two scripts you can use Update and LateUpdate to make sure the Update of the other object is already done. If you have more complex event chains you should use your own messaging system.

Comment
Add comment · Show 4 · 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
avatar image Herman-Tulleken · Aug 04, 2011 at 10:58 AM 2
Share

In addition, with Unity 3.4 you can now control the overall execution order of Starts and Updates (for example, if A is set to execute before B, then A.Awake is called before B.Awake, A.Start before B.Start, A.Update before B.Update, etc.) It can be still a challenge to set this up correctly... for instance the sequence A.Start B.Start B.Update A.Update is not possible (AFAI$$anonymous$$).

avatar image Statement · Aug 04, 2011 at 12:15 PM 0
Share

I rather guess Suyuanhan didn't already read those, since it was asked about...

avatar image Suyuanhan · Aug 05, 2011 at 01:40 AM 0
Share

Thanks,guys that helps me a lot. : )

avatar image Bunny83 · Aug 05, 2011 at 09:54 AM 0
Share

@Statement: Of course, it was a bit ironic... ;)

@Herman-Tulleken: Well, that's a nice new feature but the ordering happens per script / class and not per instance so the execution order of two instances of the same script is still "random".

Oh and Awake is only ordered at scene load since Awake is called from the constructor it'S always called directly when the object is created. Unity just orders the creation of the objects in the scene.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I stop executing a Function in a void Function? 1 Answer

communicating between scripts doesnt work 1 Answer

Inherited class, trying to overwrite variable. 0 Answers

Problem initialising slider value from code 1 Answer

MonoBehaviour execution order from Edit to Play mode and back. 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