- Home /
Select object in hierarchy before context menu appears?
MY ISSUE
I'm writing an editor script that adds buttons to Unity's hierarchy window. When the button is clicked, I want the object in the Hierarchy window to be selected (highlighted blue) before the context menu appears (which the button triggers).
if (buttonIsPressed) {
Selection.activeObject = ...;
OpenContextMenu();
}
This... almost works. The problem though is that the context menu shows up too quickly and it pauses Unity before the Hierarchy has a chance to fully re-render itself and actually highlight the object. I can see the object being highlighted after the context menu is closed. The code for the button handling is "attached" to the EditorApplication.hierarchyWindowItemOnGUI delegate.
MY QUESTION
Is there an easy way to force a full re-render of the hierarchy window before the context menu shows up? Or can I delay the menu somehow? EditorApplication.RepaintHierarchyWindow() doesn't work (menu still shows up too quickly).
Thanks!