OnEnable - Script Hot Reload - Script Execution Order

Hi,

I have a script A with an execution order set to -500.

I have a script B with no script execution order set (default time)

The order of the OnEnable calls are the following when pressing play (it’s fine):

  • A OnEnable
  • B OnEnable

I’m changing some code while playing. Once Unity has finished recompiling, the following calls are done:

  • B OnEnable
  • A OnEnable

I would have expected the follwing order (same has the initial order):

  • A OnEnable
  • B OnEnable

My goal is to have the script B listen to an event of A, and make sure the event is still register after the script recompilation:

public class B : MonoBehaviour
{
    protected void OnEnable()
    {
        Debug.Log("B OnEnable ");
        A.Instance.MyEvent.AddListener(OnAEvent);
    }
}

I’m using Unity 5.5.0f3

Thanks!

I recommend you to report that as a bug. nothing from the documentation says anything about this anomaly when hot loading.