using UnityEngine; using UnityEditor; namespace uWindowCapture { public static class EditorUtils { public static bool Foldout(string title, bool display) { var style = new GUIStyle("ShurikenModuleTitle"); style.font = new GUIStyle(EditorStyles.label).font; style.border = new RectOffset(15, 7, 4, 4); style.fixedHeight = 22; style.contentOffset = new Vector2(20f, -2f); var rect = GUILayoutUtility.GetRect(16f, 22f, style); GUI.Box(rect, title, style); var e = Event.current; var toggleRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f); if (e.type == EventType.Repaint) { EditorStyles.foldout.Draw(toggleRect, false, false, display, false); } if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition)) { display = !display; e.Use(); } return display; } public static void Fold(string name, ref bool folded, System.Action func) { folded = Foldout(name, folded); if (folded) { ++EditorGUI.indentLevel; func(); --EditorGUI.indentLevel; } } } }