Hi, I’m using UIToolkit for some behaviour inspectors, but there are some controls that I’m still implementing with IMGUI, so I’m using IMGUIContainer for those. I’ve chased a weird bug with IMGUIContainer and I’ve arrived to the conclusion that, whenever I set hierarchyMode to true inside the onGUIHandler delegate, IMGUI controls such as toggles and popups stop working. They don’t detect clicks.
Has this happen to anyone else? Any ideas on how to solve it or why it happens? If anyone has any thoughts on this, I’d really love to read them. Thank you all very much for your time, really; I appreciate it a lot. The following is an example of the problem; imagine it in a custom editor for a MonoBehaviour.
public override VisualElement CreateInspectorGUI()
{
VisualElement root = new VisualElement();
inspectorContainer = new IMGUIContainer(OnGUICallback);
root.Add(inspectorContainer);
return root;
}
void OnGUICallback()
{
//If I remove the following line, things work.
EditorGUIUtility.hierarchyMode = true;
EditorGUI.BeginChangeCheck();
EditorGUILayout.Toggle("Test control", false);
if (EditorGUI.EndChangeCheck())
//The following is only called if one clicks the toggle very quickly many times.
Debug.Log("toggled");
}