Skip to content

Instantly share code, notes, and snippets.

@nevarman
Created May 23, 2017 11:56
Show Gist options
  • Save nevarman/08b87e099f978f2feb8758546799e4ae to your computer and use it in GitHub Desktop.
Save nevarman/08b87e099f978f2feb8758546799e4ae to your computer and use it in GitHub Desktop.
public static bool CustomFoldout(string title, bool display)
{
var style = new GUIStyle("ShurikenModuleTitle")
{
font = new GUIStyle(EditorStyles.label).font,
fontStyle = FontStyle.Bold,
border = new RectOffset(15, 7, 4, 4),
fixedHeight = 22,
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment