SetExecutionOrder(MonoScript, int)
Sets the execution order for a MonoScript. This method forces Unity to reimport the MonoImporter for the target script.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
public static void SetExecutionOrder(MonoScript script, int order)
Parameters
Remarks
This is the same execution order that the Script Execution Order Settings window displays.
The default execution order for scripts is 0.
Additional Resources: MonoImporter.GetExecutionOrder.
Examples
using UnityEngine;using UnityEditor;class Example{ [MenuItem("Examples/Set Execution Order for a Script")] public static void SetExecutionOrderForAScript() { var assetPath = "Assets/MyMonoBehaviour.cs"; var monoImporter = AssetImporter.GetAtPath(assetPath) as MonoImporter; MonoImporter.SetExecutionOrder(monoImporter.GetScript(), 100); }}