- Home /
RequireComponent script order
does the RequireComponent metatag assure that the Required Component starts before the Requiring Component?
"starts" doesn't have a defined meaning; please tell us what it means to you.
"starts" in terms of when the method Start() is called by the framework
Answer by Berenger · Feb 16, 2012 at 04:52 PM
I don't think RequireComponent will change anything to the calls order. It's a little confuse in the doc, but I guess Starts are called randomly on every enabled components. If you have any object that MUST be initialized before others, use Awake. Keep in mind that awake is called even for disabled components.
Could you answer to this question: http://answers.unity3d.com/questions/217941/onenable-awake-start-order.html ? I cannot use awake in this case, I need something between awake and start!
I think, OnEnabled is called between Awake and Start. check the manual page on execution order of events.
Answer by Ashkan_gc · Feb 16, 2012 at 05:33 PM
There is no way to define the order of components execution in an object's list. i think they will be executed in the order that they are added in inspector and requireComponents will be executed one by one and at the end of the chain your script will be added. the only way to test it for script components is to have a static variable that you increment on start and print it's value with the current component's name. for none script components, it's not possible to test. maybe unity first starts all of them and then monoBehavriours.
You can not test weather none script components are initialized before scripts or not. Even none script components might be different based on their parent class. some of them are behaviours and some of them are not and ...
Your answer
![](https://koobas.hobune.stream/wayback/20220613064138im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do you prevent a base class from being addable as a script without making it abstract? 0 Answers
How Can I Get the Parent GameObject from Within a Component (C#) 4 Answers
RequireComponent - At least one of multiple types 1 Answer
Adding RequireComponent breaks script 1 Answer
Require inspector assignment? 5 Answers