public static Rect ToggleButton(Rect pos, string label, bool val, TogglePushedDelegate action) { return(ToggleButton(pos, label, val, Color.white, pos.height, action)); }
public static Rect ToggleButton(Rect pos, string label, bool val, Color colour, float height, TogglePushedDelegate action) { if (ToggleButtonStyleNormal == null) { ToggleButtonStyleNormal = "Button"; ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal); ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background; } var c = GUI.color; GUI.color = colour; if (GUI.Button(WithHeight(pos, height), label, val ? ToggleButtonStyleToggled : ToggleButtonStyleNormal)) { action(!val); } GUI.color = c; return(FromHeight(pos, height)); }