Last active
January 22, 2023 02:50
-
-
Save WSWhitehouse/371605374bb016195ab727225b599d90 to your computer and use it in GitHub Desktop.
Better EditorFoldout for Unity's Editor! Allows the user to click the foldout text as well as the arrow to toggle the foldout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------ // | |
// Author : William Whitehouse / WSWhitehouse // | |
// GitHub : github.com/WSWhitehouse // | |
// Date : 27/06/2019 // | |
// ------------------------------------------ // | |
using UnityEditor; | |
using UnityEngine; | |
public static class EditorFoldout | |
{ | |
public static bool Foldout(bool foldout, GUIContent content, GUIStyle style = null, bool toggleOnLabelClick = true) | |
{ | |
if (style == null) | |
style = EditorStyles.foldout; | |
Rect position = GUILayoutUtility.GetRect(40f, 40f, 16f, 16f, style); | |
return EditorGUI.Foldout(position, foldout, content, toggleOnLabelClick, style); | |
} | |
public static bool Foldout(bool foldout, string content, GUIStyle style = null, bool toggleOnLabelClick = true) | |
{ | |
return Foldout(foldout, new GUIContent(content), style, toggleOnLabelClick); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unity's Foldout:

foldoutBool = EditorGUILayout.Foldout(foldoutBool, new GUIContent("Foldout Test"));
New EditorFoldout:

foldoutBool = EditorFoldout.Foldout(foldoutBool, new GUIContent("Foldout Test"));