Example #1
0
        public static void Draw(Rect position, GUIContent label, SerializedProperty property, ClassDisplayType type)
        {
            if (type == ClassDisplayType.Inline)
            {
                DrawChildren(position, property, null);
            }
            else if (type == ClassDisplayType.Propogated)
            {
                DrawChildren(position, property, label);
            }
            else if (type == ClassDisplayType.Foldout)
            {
                var labelRect = RectHelper.TakeLine(ref position);

                property.isExpanded = FoldoutSection.Draw(labelRect, label, property.isExpanded);

                if (property.isExpanded)
                {
                    using (new EditorGUI.IndentLevelScope())
                        DrawChildren(position, property, null);
                }
            }
            else
            {
                var labelRect = RectHelper.TakeLine(ref position);
                EditorGUI.LabelField(labelRect, label);

                using (new EditorGUI.IndentLevelScope())
                    DrawChildren(position, property, null);
            }
        }
        public static string DrawFoldoutArea(Rect position, GUIContent label, string value, ref bool isExpanded, bool fullWidth, bool wordWrap)
        {
            var fullRect  = position;
            var lineRect  = RectHelper.TakeLine(ref position);
            var labelRect = !fullWidth || !isExpanded?RectHelper.TakeLabel(ref lineRect) : lineRect;

            isExpanded = FoldoutSection.Draw(labelRect, label, isExpanded);

            if (isExpanded)
            {
                if (fullWidth)
                {
                    using (new EditorGUI.IndentLevelScope())
                        return(DrawArea(position, value, wordWrap));
                }
                else
                {
                    RectHelper.TakeLabel(ref fullRect);
                    return(DrawArea(fullRect, value, wordWrap));
                }
            }
            else
            {
                return(EditorGUI.TextField(lineRect, value));
            }
        }
        public static string DrawFoldoutPopup(Rect position, GUIContent label, string value, ref bool isExpanded, string[] options)
        {
            var lineRect  = RectHelper.TakeLine(ref position);
            var labelRect = isExpanded ? lineRect : RectHelper.TakeLabel(ref lineRect);

            isExpanded = FoldoutSection.Draw(labelRect, label, isExpanded);

            if (isExpanded)
            {
                return(DrawPopup(position, value, options));
            }
            else
            {
                return(DrawPopup(lineRect, value, options));
            }
        }
        public static string DrawFoldoutField(Rect position, GUIContent label, string value, ref bool isExpanded)
        {
            var lineRect  = RectHelper.TakeLine(ref position);
            var labelRect = isExpanded ? lineRect : RectHelper.TakeLabel(ref lineRect);

            isExpanded = FoldoutSection.Draw(labelRect, label, isExpanded);

            if (isExpanded)
            {
                return(EditorGUI.TextField(position, value));
            }
            else
            {
                return(EditorGUI.TextField(lineRect, value));
            }
        }