Is there a specific order in which the update
method is called for components added in Flame? For example, in Unity, the LateUpdate
method is available to ensure certain updates, like the camera update, are executed last.
Is it called in the order it was added? Or is the order random?
2
Answers
Checkout Order of Execution documentation: https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html
You can change order of execution like in this thread with an Attribute: https://stackoverflow.com/questions/27928474/programmatically-define-execution-order-of-scripts#:~:text=you%20can%20use%20the%20attribute%3A
I like to have in general just one Monobehaviour and the rest are normal C# classes (until you need some prefabs and scripts which do change just one single object) and the main Monobehaviour controls which Update is called first. Anyway you could also use Events for some particular cases.
The order of update is decided depending on the
priority
of the component, and if two components have the same priority they are updated in the order that they were added. But, this only applies to sibling components, the component tree updates start in the root and then it traverses down to the leaf components.