Documenting the dark corners of the Unity Engine.

User Tools

Site Tools



An undocumented attribute that modifies the execution order of all event functions in a MonoBehaviour class. This functionality is identical to the Script Execution Order settings in the Project Settings window, except that it's encoded directly in the script instead of through the editor.

It has a single integer argument: the offset for the execution order. Negative numbers are early, positive numbers are late. For example:

public class MyClass : MonoBehaviour {
    void Start () {
        Debug.Log("Early bird catches the worm!");

The Start function in this class will be called before the Start calls in any other class (unless those other classes have their own, smaller offset). Importantly, the global order of events will never be changed, so this Start function won't be called before any OnEnable or Awake functions.

It's worth noting that, although the Script Execution Order settings window has the same functionality, it doesn't list scripts whose execution order offsets are set with this attribute.

A full list of Unity's event functions and their relative order can be found here.

defaultexecutionorder.txt · Last modified: 2021/04/30 15:29 by sam_suite