Skip to content

Instantly share code, notes, and snippets.

Last active July 4, 2018 16:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add this to a MonoBehaviour to set its Script Execution Order without access to the editor.
private const int executionOrder = -1000;
private static void SetScriptOrder()
var go = new GameObject("Temp");
var monoScript = UnityEditor.MonoScript.FromMonoBehaviour(go.AddComponent<NAME_OF_THIS_MONOBEHAVIOUR>());
if (UnityEditor.MonoImporter.GetExecutionOrder(monoScript) != executionOrder)
UnityEditor.MonoImporter.SetExecutionOrder(monoScript, executionOrder);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment