private void PaintHeader(SerializedProperty spEnabled, AnimBool state, string title) { EditorGUILayout.BeginHorizontal(); GUIStyle style = (spEnabled.boolValue ? CoreGUIStyles.GetToggleButtonOn() : CoreGUIStyles.GetToggleButtonOff() ); bool buttonPressed = GUILayout.Button(title, style); Rect buttonRect = GUILayoutUtility.GetLastRect(); if (buttonPressed) { spEnabled.boolValue = !spEnabled.boolValue; state.target = spEnabled.boolValue; } if (UnityEngine.Event.current.type == EventType.Repaint) { Rect toggleRect = new Rect( buttonRect.x + 5f, buttonRect.y + (buttonRect.height / 2 - 8), 12, 12 ); bool isOn = spEnabled.boolValue; EditorStyles.toggle.Draw(toggleRect, GUIContent.none, false, false, isOn, isOn); } EditorGUILayout.EndHorizontal(); }