public static void BeginObjectFieldFoldGroup <T>(string title, ObjectFieldToggleParameter parameter, bool allowSceneObject, bool showRemoveButton, Action <T> onValueChanged, Func <bool> validate) where T : Object
        {
            var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            var labelRect = backgroundRect;

            labelRect.xMin += 32f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;

            foldoutRect.y     += 1f;
            foldoutRect.width  = 13f;
            foldoutRect.height = 13f;

            backgroundRect.xMin   = 0f;
            backgroundRect.width += 4f;

            // Background
            EditorGUI.DrawRect(backgroundRect, Styles.HeaderBackgroundColor);

            var origFontStyle = EditorStyles.label.fontStyle;

            EditorStyles.label.fontStyle = FontStyle.Bold;
            EditorCustomGUI.ObjectField(labelRect, title, (T)parameter.Content, allowSceneObject, showRemoveButton, onValueChanged, validate);
            EditorStyles.label.fontStyle = origFontStyle;

            // foldout
            parameter.Fold = GUI.Toggle(foldoutRect, parameter.Fold, GUIContent.none, EditorStyles.foldout);

            // Handle events
            var e = Event.current;

            if (e.type == EventType.MouseDown)
            {
                if (labelRect.Contains(e.mousePosition))
                {
                    if (e.button == 0)
                    {
                        parameter.Fold = !parameter.Fold;
                    }

                    e.Use();
                }
            }

            EditorGUILayout.BeginVertical();
            ObjectFieldFoldGroupStack.Push(parameter);
        }
 public ObjectFieldFoldGroupScope(string title, ObjectFieldToggleParameter parameter, bool allowSceneObject, bool showRemoveButton, Action <T> onValueChanged, Func <bool> validate)
 {
     BeginObjectFieldFoldGroup(title, parameter, allowSceneObject, showRemoveButton, onValueChanged, validate);
 }