Version 3.3.0.1

UnityEditorEventUtility class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.Utilities.Editor
public static class UnityEditorEventUtility
This class contains utility methods for subscribing to various UnityEditor events reliably and safely across all Odin-supported versions of Unity.
Inheritance
  • System.Object
  • UnityEditorEventUtility

Fields

HasOnProjectChanged
public static readonly bool HasOnProjectChanged

Methods

DelayAction(Action)
Sometimes, an idiot overrides a delay action subscription to UnityEditor.EditorApplication.delayCall, which can be done because the people at Unity didn't know what events were once upon a time. This method subscribes to a lot of different callbacks, in the hopes of catching at least one.
public static void DelayAction(Action action)
Parameters
System.Action action

DelayAction(Action, Boolean)
Sometimes, an idiot overrides a delay action subscription to UnityEditor.EditorApplication.delayCall, which can be done because the people at Unity didn't know what events were once upon a time. This method subscribes to a lot of different callbacks, in the hopes of catching at least one.
public static void DelayAction(Action action, bool excludeGuiEventHooks)
Parameters
System.Action action

System.Boolean excludeGuiEventHooks

DelayActionThreadSafe(Action)
Sometimes, someone accidentally overrides a delay action subscription to UnityEditor.EditorApplication.delayCall by setting the value instead of using the += operator as should be done, which can be done because in many versions of Unity it is a field, and not an event. (In some versions of Unity it is an event, though, and in this case, this method acts as a wrapper to subscribe reliably, no matter the nature of the backing event.) This method subscribes to a lot of different callbacks, in the hopes of catching at least one.

As opposed to DelayAction(Action), this method is safe to call from any thread, and will delay the actual subscription to a safe time.

public static void DelayActionThreadSafe(Action action)
Parameters
System.Action action

Events

DuringSceneGUI
In 2019.1+, this event subscribes to SceneView.duringSceneGui. In 2018.4 and lower, it subscribes to SceneView.onSceneGUIDelegate.
public static event Action<SceneView> DuringSceneGUI
EditorApplication_delayCall
In 2020.1, Unity changed EditorApplication.delayCall from a field to an event, meaning we now have to use reflection to access it consistently across all versions of Unity.
public static event Action EditorApplication_delayCall
OnProjectChanged
public static event Action OnProjectChanged