//void OnDisable() { // //Debug.Log("OnDisable"); // EditorApplication.hierarchyWindowChanged -= HierarchyChanged; //} private static void HierarchyChanged() { //Debug.Log("HierarchyChanged! " + options.Count + " - " + selected); if (options.Count > selected) { string oldValue = options[selected]; myScript = (GUIGenerator)instance.target; options = myScript.GetMainPanels(); if (options[selected] != oldValue) { for (int i = 0; i < options.Count; ++i) { if (options[i] == oldValue) { selected = i; break; } } } } else { options = myScript.GetMainPanels(); } }