1.
ExLifeCycle script is attached into All GameObjects (ex: Parent, Child1, ... )
public class ExLifeCycle : MonoBehaviour
{
private void Awake()
{
Debug.Log($"{name}:Awake");
}
private void OnEnable()
{
Debug.Log($"{name}:OnEnable");
}
void Start()
{
Debug.Log($"{name}:Start");
}
}
When Playing, the follow logs comes
----------------------
Child1:Awake
Child1:OnEnable
SubChild(1):Awake
SubChild(1):OnEnable
Child1(3):Awake
Child1(3):OnEnable
Parent:Awake
Parent:OnEnable
Child1(2):Awake
Child1(2):OnEnable
.....
Child1:Start
SubChild(1):Start
...
the calling order of GameObject Awake,Enable is not fixed, and random.
and After All gameObject OnEnable() are called, Start() of all are called.
2.