diff --git a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs index 7b16f95e3..a25a98c86 100644 --- a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs +++ b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs @@ -42,6 +42,7 @@ namespace FlaxEngine.GUI float left = _margin.Left; float right = _margin.Right; float h = Height - _margin.Height; + float maxHeight = h; bool hasAnyLeft = false, hasAnyRight = false; for (int i = 0; i < _children.Count; i++) { @@ -62,6 +63,7 @@ namespace FlaxEngine.GUI c.Bounds = new Rectangle(Width - right + _offset.X, _margin.Top + _offset.Y, w, ch); hasAnyRight = true; } + maxHeight = Mathf.Max(maxHeight, ch); } } if (hasAnyLeft) @@ -71,7 +73,13 @@ namespace FlaxEngine.GUI // Update size if (_autoSize) - Width = left + right; + { + var size = Size; + size.X = left + right; + if (!ControlChildSize) + size.Y = maxHeight; + Size = size; + } } } } diff --git a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs index 7a8785f4c..9ee2a2297 100644 --- a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs +++ b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs @@ -42,6 +42,7 @@ namespace FlaxEngine.GUI float top = _margin.Top; float bottom = _margin.Bottom; float w = Width - _margin.Width; + float maxWidth = w; bool hasAnyTop = false, hasAnyBottom = false; for (int i = 0; i < _children.Count; i++) { @@ -62,6 +63,7 @@ namespace FlaxEngine.GUI c.Bounds = new Rectangle(_margin.Left + _offset.X, Height - bottom + _offset.Y, cw, h); hasAnyBottom = true; } + maxWidth = Mathf.Max(maxWidth, cw); } } if (hasAnyTop) @@ -71,7 +73,13 @@ namespace FlaxEngine.GUI // Update size if (_autoSize) - Height = top + bottom; + { + var size = Size; + size.Y = top + bottom; + if (!ControlChildSize) + size.X = maxWidth; + Size = size; + } } } }