P
P
Pragma Games2021-12-18 11:16:33
Unity
Pragma Games, 2021-12-18 11:16:33

In what order are OnEnables called on a complex object?

Hello. I have nested GameObjects on the stage that have scripts attached to them. Every script has an OnEnable. Previously, I always thought that the root OnEnable is called first, then it goes to the child ones, and so on, that is, from top to bottom. But today I noticed the reverse order of the call, starting from the bottom up, that is, from the most nested to the parent. It seemed strange to me, I decided to double-check it, made clones of identical objects, started turning them on one by one and it turned out that the call order was really random. Either from root to child, or from child to root. Explain why this is happening. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question