public override float GetHeight(SerializedProperty property, GUIContent label, float height)
        {
            if (!IsVisible())
            {
                return(height);
            }

            var data = m_Data.Get(property.propertyPath);

            data.height = height;
            GetProperties(data.properties);
            data.propertyHeights.Clear();

            var widths = m_Widths.AsEnumerable();
            int diff   = data.properties.Count + 1 - m_Widths.Length;

            if (diff > 0)
            {
                widths = widths.Concat(Enumerable.Repeat(-1f, diff));
            }
            widths = widths.Take(data.properties.Count + 1);

            int index = -1;

            InGroupAttribute.Add(m_Name);
            float result = 0;

            foreach (var width in widths)
            {
                if (index < 0 && width != 0)
                {
                    result = Mathf.Max(data.height, result);
                }
                if (index >= 0)
                {
                    height = data.properties[index] == null ? 0 : EditorGUI.GetPropertyHeight(data.properties[index], null, true);
                    if (height < 0)
                    {
                        height = 0;
                    }
                    data.propertyHeights.Add(height);
                    if (width != 0)
                    {
                        result = Mathf.Max(height, result);
                    }
                }
                index++;
            }
            InGroupAttribute.Remove(m_Name);
            result = Mathf.Max(0, result);
            return(result);
        }
Exemplo n.º 2
0
        public override bool BeforeGUI(ref Rect position, ref SerializedProperty property, ref GUIContent label, ref bool includeChildren, bool visible)
        {
            m_SavedIndentLevel = EditorGUI.indentLevel;
            if (!IsVisible())
            {
                return(visible);
            }
            if (!visible)
            {
                return(false);
            }
            if (Event.current.type == EventType.Layout)
            {
                return(visible);
            }

            var text    = label.text;
            var image   = label.image;
            var tooltip = label.tooltip;

            var rect = position.indent(indented);

            var data = m_Data.Get(property.propertyPath);

            GetProperties(data.properties);

            int index = -1;

            if (indentChildren)
            {
                EditorGUI.indentLevel++;
            }
            InGroupAttribute.Add(m_Name);
            foreach (var cell in rect.VerticalDistribute(spacing, data.rowHeights))
            {
                if (index < 0)
                {
                    position = cell;
                }
                else if (data.properties[index] != null && cell.height > 0)
                {
                    EditorGUI.PropertyField(cell.Height(data.propertyHeights[index]), data.properties[index], null, true);
                }
                index++;
            }
            InGroupAttribute.Remove(m_Name);

            label.text    = text;
            label.image   = image;
            label.tooltip = tooltip;
            return(position.height > 0);
        }
Exemplo n.º 3
0
        public override float GetHeight(SerializedProperty property, GUIContent label, float height)
        {
            if (!IsVisible())
            {
                return(height);
            }

            Update();
            var data = m_Data.Get(property.propertyPath);

            property.GetProperties(m_Properties, data.properties);

            float toolbar = m_ToolbarSize.y;

            toolbar += m_Top + m_Bottom;
            if (toolbar < 0)
            {
                toolbar = 0;
            }

            float h = 0;

            if (m_TabIndex == 0)
            {
                h = height;
            }
            else
            {
                InGroupAttribute.Add(m_Name);
                if (data.properties[m_TabIndex - 1] != null)
                {
                    h = EditorGUI.GetPropertyHeight(data.properties[m_TabIndex - 1], null, true);
                }
                InGroupAttribute.Remove(m_Name);
            }
            data.tabHeight = h;

            return(toolbar + h);
        }
Exemplo n.º 4
0
        public override bool BeforeGUI(ref Rect position, ref SerializedProperty property, ref GUIContent label, ref bool includeChildren, bool visible)
        {
            if (!IsVisible())
            {
                return(visible);
            }
            if (!visible)
            {
                return(false);
            }
            if (Event.current.type == EventType.Layout)
            {
                return(visible);
            }

            Update();
            var data = m_Data.Get(property.propertyPath);

            property.GetProperties(m_Properties, data.properties);

            var indent = position.indent(indented);
            var rect   = new Rect(indent);

            rect.xMin  += m_Left;
            rect.xMax  -= m_Right;
            rect.y     += m_Top;
            rect.height = m_ToolbarSize.y;
            GUI.Label(rect, GUIContent.none, m_Style2);

            rect = new Rect(indent);
            float width = 0;

            if (this.width < 0)
            {
                width = m_ToolbarSize.x;
            }
            else if (this.width <= 1)
            {
                width = indent.width * this.width;
            }
            else
            {
                width = this.width;
            }
            rect.width  = width;
            rect.y     += m_Top;
            rect.height = m_ToolbarSize.y;

            if (alignment == TextAlignment.Right)
            {
                rect.xMin = indent.xMax - rect.width;
                rect.xMax = indent.xMax;
            }
            else if (alignment == TextAlignment.Center)
            {
                rect.x += (indent.width - rect.width) / 2;
            }
            rect.xMin += m_Left;
            rect.xMax -= m_Right;

            var tab = (int)m_ButtonGroup.Draw(rect, m_TabIndex, m_Contents.Length);

            float toolbar = m_ToolbarSize.y + m_Top + m_Bottom;

            if (toolbar < 0)
            {
                toolbar = 0;
            }
            position.yMin += toolbar;

            if (m_TabIndex > 0)
            {
                InGroupAttribute.Add(m_Name);
                if (data.properties[m_TabIndex - 1] != null)
                {
                    EditorGUI.PropertyField(position.Height(data.tabHeight), data.properties[m_TabIndex - 1], null, true);
                }
                InGroupAttribute.Remove(m_Name);
            }

            var result = m_TabIndex == 0;

            m_TabIndex = tab;
            return(result);
        }
        public override bool BeforeGUI(ref Rect position, ref SerializedProperty property, ref GUIContent label, ref bool includeChildren, bool visible)
        {
            if (!IsVisible())
            {
                return(visible);
            }
            if (!visible)
            {
                return(false);
            }
            if (Event.current.type == EventType.Layout)
            {
                return(visible);
            }

            var text    = label.text;
            var image   = label.image;
            var tooltip = label.tooltip;

            var content = m_Content;

            if (title == null)
            {
                content.text = text;
            }
            if (icon == null)
            {
                content.image = image;
            }
            if (tooltip == null)
            {
                content.tooltip = tooltip;
            }
            Rect rect;

            if (prefix)
            {
                rect = EditorGUI.PrefixLabel(position, content, m_Style);
            }
            else
            {
                rect = indented ? EditorGUI.IndentedRect(position) : new Rect(position);
            }

            var data = m_Data.Get(property.propertyPath);

            var widths = m_Widths.AsEnumerable();
            int diff   = data.properties.Count + 1 - m_Widths.Length;

            if (diff > 0)
            {
                widths = widths.Concat(Enumerable.Repeat(-1f, diff));
            }
            widths = widths.Take(data.properties.Count + 1);

            int index       = -1;
            var indentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            InGroupAttribute.Add(m_Name);
            foreach (var cell in rect.HorizontalDistribute(spacing, widths))
            {
                if (index < 0)
                {
                    position = cell.Height(data.height);
                }
                else if (data.properties[index] != null && cell.width > 0)
                {
                    var h = data.propertyHeights[index];
                    EditorGUI.PropertyField(cell.Height(h), data.properties[index], null, true);
                }
                index++;
            }
            InGroupAttribute.Remove(m_Name);
            EditorGUI.indentLevel = indentLevel;

            label.text    = text;
            label.image   = image;
            label.tooltip = tooltip;
            return(position.width > 0);
        }
Exemplo n.º 6
0
        public override float GetHeight(SerializedProperty property, GUIContent label, float height)
        {
            if (!IsVisible())
            {
                return(height);
            }

            var data = m_Data.Get(property.propertyPath);

            GetProperties(data.properties);
            data.propertyHeights.Clear();
            data.rowHeights.Clear();

            var heights = m_Heights.AsEnumerable();
            int diff    = data.properties.Count + 1 - m_Heights.Length;

            if (diff > 0)
            {
                heights = heights.Concat(Enumerable.Repeat(-1f, diff));
            }
            heights = heights.Take(data.properties.Count + 1);

            int   index  = -1;
            float result = 0;

            InGroupAttribute.Add(m_Name);
            foreach (var h in heights)
            {
                if (index < 0)
                {
                    height = h >= 0 ? h : height;
                }
                else
                {
                    var propertyHeight = data.properties[index] == null ? 0 : EditorGUI.GetPropertyHeight(data.properties[index], null, true);
                    data.propertyHeights.Add(propertyHeight);

                    if (h >= 0)
                    {
                        height = h;
                    }
                    else
                    {
                        height = propertyHeight;
                    }
                }

                if (height < 0)
                {
                    height = 0;
                }
                data.rowHeights.Add(height);
                if (result > 0 && height > 0)
                {
                    result += spacing;
                }
                result += height;
                index++;
            }
            InGroupAttribute.Remove(m_Name);
            return(result);
        }