Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Tomer-Barkan · Nov 15, 2013 at 07:47 PM · instantiateupdatemonobehaviourstart

Start being called after Update of another GameObject?

I've got a very very weird scenario...

I've got two GameObjects - parent and child. Each one has its own script. The parent has an Update() method, while the child has a Start(). The parent prefab is instantiated from a Start() method of a third object (separate object hierarchy).

Now the first time the level is loaded, the parent is instantiated fine with it's child, and all works as expected. Then I load another level, and reload this level again. This time, when I load the level, the parent object is instantiated fine, but for some reason, the Update() of the parent object is called before the Start() of the child object. I figured this is very weird since they are both instantiated at the same time, so I'd expect the Start() calls to happen before the Update() calls...

Can anyone explain? Is this a bug?

I'd note that I couldn't get this to reproduce in a minimal project, and my project is kinda large already... But for sure this is the only place where these scripts are attached.

Update:

I changed the Start() to Awake() and it works fine now, always calls the Awake() before any other Update(). Unity bug?

Comment
Add comment · Show 2
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 tanoshimi · Nov 15, 2013 at 08:14 PM 0
Share

By default, the Awake, OnEnable and Update functions of different scripts are called in the order the scripts are loaded (which is arbitrary). However, it is possible to modify this order using the Script Execution Order settings. See: http://docs.unity3d.com/Documentation/Components/class-ScriptExecution.html

avatar image Tomer-Barkan tanoshimi · Nov 15, 2013 at 09:03 PM 0
Share

Yeah, but I'm talking about an Update() being called before Start()... And according to the $$anonymous$$onoBehaviour.Start() documentation:

Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.

So I'd expect the Start() to be called before Update() regardless of the script execution order.

0 Replies

· Add your reply
  • Sort: 

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Update and Awake not being called. 1 Answer

how to call something just once from an update function 5 Answers

Start() not called upon instantation? 1 Answer

Start, Awake, Update. Any other ways to call functions from an empty GameObject? 3 Answers

My randomly generated slope game doesn't seem to work? 0 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