private Rect DrawFoldable(Rect rect, MetadataWrapper wrapper, Action <object> changeValueCallback, GUIContent label, bool isPartOfHeader) { if (wrapper.Metadata[foldableName] == null) { wrapper.Metadata[foldableName] = true; changeValueCallback(wrapper); } bool oldIsFoldedOutValue = (bool)wrapper.Metadata[foldableName]; GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout) { fontStyle = FontStyle.Bold, fontSize = 12 }; GUIStyle labelStyle = new GUIStyle(EditorStyles.label) { fontStyle = FontStyle.Bold, fontSize = 12 }; Rect foldoutRect = new Rect(rect.x, rect.y, rect.width, EditorDrawingHelper.HeaderLineHeight); if (isPartOfHeader) { EditorGUI.DrawRect(new Rect(0, foldoutRect.y, foldoutRect.width + foldoutRect.x + 8, foldoutRect.height), new Color(62f / 256f, 62f / 256f, 62f / 256f)); EditorGUI.DrawRect(new Rect(0, foldoutRect.y, foldoutRect.width + foldoutRect.x + 8, 1), new Color(26f / 256f, 26f / 256f, 26f / 256f)); EditorGUI.DrawRect(new Rect(0, foldoutRect.y + foldoutRect.height, foldoutRect.width + foldoutRect.x + 8, 1), new Color(48f / 256f, 48f / 256f, 48f / 256f)); } bool newIsFoldedOutValue = EditorDrawingHelper.DrawFoldoutWithReducedFocusArea(foldoutRect, oldIsFoldedOutValue, oldIsFoldedOutValue ? new GUIContent() : label, foldoutStyle, labelStyle); if (newIsFoldedOutValue != oldIsFoldedOutValue) { wrapper.Metadata[foldableName] = newIsFoldedOutValue; changeValueCallback(wrapper); } // Collapsed if (newIsFoldedOutValue == false) { rect.height = EditorDrawingHelper.HeaderLineHeight; return(rect); } rect.height = 0f; Rect wrappedRect = rect; wrappedRect.x += EditorDrawingHelper.IndentationWidth; wrappedRect.width -= EditorDrawingHelper.IndentationWidth; return(DrawRecursively(wrappedRect, wrapper, foldableName, (newWrapper) => { // We want the user to be aware that value has changed even if the foldable was collapsed (for example, undo/redo). wrapper.Metadata[foldableName] = true; changeValueCallback(wrapper); }, label)); }