コード例 #1
0
        /// <summary>
        ///     Draws the foldout.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="position">Position.</param>
        public static bool DrawFoldout(GUIContent title, Rect position)
        {
            bool state = EditorPrefsUtils.GetFoldoutState(title);

            bool newState = EditorGUI.Foldout(position, state, title);

            if (newState != state)
            {
                EditorPrefsUtils.SetFoldoutState(title, newState);
            }

            return(newState);
        }
コード例 #2
0
        /// <summary>
        ///     Draws a foldout and uses the drawContentsMethod to fill it.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="drawContentsMethod">Draw contents method.</param>
        public static bool DrawFoldout(GUIContent title, Action drawContentsMethod)
        {
            bool state = EditorPrefsUtils.GetFoldoutState(title);

            bool newState = EditorGUILayout.Foldout(state, title);

            if (newState)
            {
                int indentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel++;

                drawContentsMethod();

                EditorGUI.indentLevel = indentLevel;
            }

            if (newState != state)
            {
                EditorPrefsUtils.SetFoldoutState(title, newState);
            }

            return(newState);
        }