I had some weird behavior in my code which took some time to find the problem.
I have two scripts, one works with the data OnEnable, other on Awake, i added debugs to see execution order.
public class Player : MonoBehaviour {
private void OnEnable(){
Debug.Log ("registering events");
}
}
public class InputManager : MonoBehaviour{
private void Awake(){
Debug.Log("awake");
}
}
Console
How is this possible? Docs clearly show that OnEnable is called after Awake.
All gameobjects components live on are active and components enabled.
Project came from other dev, is it possible he changed execution order (not sure if thats possible).
Ive never seen anything like this.
Edit:
I just created two empty scripts A and B with only this code in each of them, each on its own dummy gameobject, execution order is correct for them. I even attached these components to same gameObjects, execution order is still correct, but reversed on old scripts!