Where can I initialize EditorApplication.hierarchyWindowItem without the user having to explicitly run a script? Like something that runs as Unity starts up, or an attribute that automatically runs a function as unity starts.
I know this is very vague, but I hope someone out there can lend a hand.
EditorApplication.hierarchyWindowItem is the type of hierarchyWindowItemOnGUI. It exists to define the signature of the delegates you subscribe to hierarchyWindowItemOnGUI which is define as
public static EditorApplication.HierarchyWindowItemCallback hierarchyWindowItemOnGUI;
So there is no correct use in a strict sense, though you are using it correctly when you use hierarchyWindowItemOnGUI.
Here’s a minimal example:
[InitializeOnLoad]
public class HierarchyStyler {
static HierarchyStyler()
{
Debug.Log("Initialized");
EditorApplication.hierarchyWindowItemOnGUI += hwCallbackDelegate;
}
static void hwCallbackDelegate(int _instanceID, Rect _selectionRect)
{
Debug.Log("CALLBACK");
}
}
You should see some heavy printout in the console.