diff --git a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
index d6e98315a..2145dc810 100644
--- a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
@@ -44,6 +44,11 @@ namespace FlaxEngine.GUI
float h = Height - _margin.Height;
float maxHeight = h;
bool hasAnyLeft = false, hasAnyRight = false;
+
+ float totalGaps = (_children.Count - 1) * Spacing;
+ float availableWidth = Width - totalGaps - LeftMargin - RightMargin;
+ float itemWidth = availableWidth / _children.Count;
+
for (int i = 0; i < _children.Count; i++)
{
Control c = _children[i];
@@ -64,6 +69,11 @@ namespace FlaxEngine.GUI
hasAnyRight = true;
}
maxHeight = Mathf.Max(maxHeight, ch);
+
+ if (ExpandChildren)
+ {
+ c.Width = itemWidth;
+ }
}
}
if (hasAnyLeft)
diff --git a/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs b/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs
index 52222946e..3223272ad 100644
--- a/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs
+++ b/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs
@@ -160,6 +160,12 @@ namespace FlaxEngine.GUI
[EditorOrder(35), DefaultValue(true), Tooltip("If checked, the panel can resize children controls (eg. auto-fit width/height).")]
public bool ControlChildSize { get; set; } = true;
+ ///
+ /// Gets or sets the value indicating whenever the panel can resize children controls (eg. auto-fit width/height).
+ ///
+ [EditorOrder(36), DefaultValue(false), Tooltip("If checked, the panel will expand all children in the relevant direction with even spacing and size. (Horizontally for Horizontal Panel, Vertically for Vertical Panel).")]
+ public bool ExpandChildren { get; set; } = false;
+
///
/// Gets or sets the panel area margin.
///
diff --git a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
index 722da1fdc..9036d88fb 100644
--- a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
@@ -1,5 +1,7 @@
// Copyright (c) Wojciech Figat. All rights reserved.
+using System.Globalization;
+
namespace FlaxEngine.GUI
{
///
@@ -44,6 +46,11 @@ namespace FlaxEngine.GUI
float w = Width - _margin.Width;
float maxWidth = w;
bool hasAnyTop = false, hasAnyBottom = false;
+
+ float totalGaps = (_children.Count - 1) * Spacing;
+ float availableHeight = Height - totalGaps - TopMargin - BottomMargin;
+ float itemHeight = availableHeight / _children.Count;
+
for (int i = 0; i < _children.Count; i++)
{
Control c = _children[i];
@@ -64,6 +71,11 @@ namespace FlaxEngine.GUI
hasAnyBottom = true;
}
maxWidth = Mathf.Max(maxWidth, cw);
+
+ if (ExpandChildren)
+ {
+ c.Height = itemHeight;
+ }
}
}
if (hasAnyTop)