/// <summary> /// Called when it is time for this MonoBehaviour to draw its GUI. /// </summary> void OnGUI() { if (!showUI) { return; } // make sure the objects are still valid for (int i = 0; i < selectionChain.Count; i++) { if (selectionChain[i] == null || selectionChain[i].gameObject == null) { ClearSelection(); break; } } for (int i = rootTransforms.Count - 1; i >= 0; i--) { if (rootTransforms[i] == null || rootTransforms[i].gameObject == null) { rootTransforms.RemoveAt(i); } } // Draw the Hierarchy window. hierarchyRect = GUI.Window(GetInstanceID(), hierarchyRect, HierarchyWindow, "Hierarchy", HighLogic.Skin.window); // If there is something in the selection chain, if (!ReferenceEquals(selectedTransform, null)) { // If the inspector is null, if (inspector == null) { // Create a new inspector. inspector = new Inspector(this, GetInstanceID() + 1, hierarchyRect); } // Draw the inspector GUI. inspector.DrawGUI(selectedTransform); if (editor != null) { editor.DrawGUI(); } DrawSelectionRectTransform(); } else { if (editor != null) { editor = null; } if (inspector != null) { inspector.isVisible = false; } } DisableMouseWheel(); }