public void DrawDirectoryTreeElement(bool mouseUp, Vector2 mousePos, bool isShown = true, bool isBase = true) { this.isShown = isShown; if (isShown) { if (!isBase) { GUIUtils.BeginIndent(); } EditorGUILayout.BeginHorizontal(); bool hasChildren = directoryChildIDs.Count > 0; GUI.enabled = hasChildren; showChildren = GUIUtils.SmallToggleButton(new GUIContent("", "Show Children"), showChildren, out _); GUI.enabled = true; Rect rect = BuildGUIRectAndCalculateMousePos(mousePos); bool dropReceived, beingDragged; baseSystem.dragDropHandler.ElementDragDropValues(this, mousePos, mouseUp, out beingDragged, out receiverHovered, out dropReceived); bool drawSelected = receiverHovered || elementID == baseSystem.currentShownDirectoryID; bool guiEnabled = !dropReceived; bool drawBackground = false; DrawButtonBase(rect, drawSelected, drawBackground, guiEnabled, Colors.liteGray, FontStyle.Normal); EditorGUILayout.EndHorizontal(); if (hasChildren) { foreach (var child in directoryChildIDs) { baseSystem.GetDirectoryTreeElement(child).DrawDirectoryTreeElement(mouseUp, mousePos, showChildren && isShown, false); } } if (!isBase) { GUIUtils.EndIndent(); } } }
void OnGUI() { if (CloseIfError()) { Close(); return; } UnityEngine.Event inputEvent = UnityEngine.Event.current; bool mouseUp = inputEvent.rawType == EventType.MouseUp; GUIUtils.StartBox(1); GUI.backgroundColor = Colors.white; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); Vector2 mousePos = inputEvent.mousePosition; baseSystem.GetDirectoryTreeElement(0).DrawDirectoryTreeElement(mouseUp, mousePos); baseSystem.dragDropHandler.UpdateLoopReceiverOnly(mousePos); EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); if (GUIUtils.Button(closeGUI, GUIStyles.button, Colors.blue, Colors.black)) { Close(); } GUIUtils.EndBox(1); baseSystem.serializedObject.SaveObject(); }