diff --git a/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs b/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs
index 6c112d9d5..2353a5d99 100644
--- a/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs
@@ -11,6 +11,7 @@ namespace FlaxEngine.GUI
{
private Margin _slotPadding;
private int _slotsV, _slotsH;
+ private Float2 _slotSpacing;
///
/// Gets or sets the padding given to each slot.
@@ -62,11 +63,25 @@ namespace FlaxEngine.GUI
}
}
+ ///
+ /// Gets or sets grid slot spacing.
+ ///
+ [EditorOrder(30), Limit(0), Tooltip("The Grid slot spacing.")]
+ public Float2 SlotSpacing
+ {
+ get => _slotSpacing;
+ set
+ {
+ _slotSpacing = value;
+ PerformLayout();
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
public UniformGridPanel()
- : this(2)
+ : this(0)
{
}
@@ -74,10 +89,11 @@ namespace FlaxEngine.GUI
/// Initializes a new instance of the class.
///
/// The slot padding.
- public UniformGridPanel(float slotPadding = 2)
+ public UniformGridPanel(float slotPadding = 0)
{
AutoFocus = false;
SlotPadding = new Margin(slotPadding);
+ SlotSpacing = new Float2(2);
_slotsH = _slotsV = 5;
}
@@ -122,6 +138,42 @@ namespace FlaxEngine.GUI
var slotBounds = new Rectangle(slotSize.X * x, slotSize.Y * y, slotSize.X, slotSize.Y);
_slotPadding.ShrinkRectangle(ref slotBounds);
+ if (slotsV > 1)
+ {
+ if (y == 0)
+ {
+ slotBounds.Height -= _slotSpacing.Y * 0.5f * slotsV;
+ }
+ else if (y == slotsV - 1)
+ {
+ slotBounds.Height -= _slotSpacing.Y * 0.5f * slotsV;
+ slotBounds.Y += _slotSpacing.Y * 0.5f * slotsV;
+ }
+ else
+ {
+ slotBounds.Height -= _slotSpacing.Y * 0.5f * slotsV;
+ slotBounds.Y += _slotSpacing.Y * 0.5f;
+ }
+ }
+
+ if (slotsH > 1)
+ {
+ if (x == 0)
+ {
+ slotBounds.Width -= _slotSpacing.X * 0.5f * slotsH;
+ }
+ else if (x == slotsH - 1)
+ {
+ slotBounds.Width -= _slotSpacing.X * 0.5f * slotsH;
+ slotBounds.X += _slotSpacing.X * 0.5f * slotsH;
+ }
+ else
+ {
+ slotBounds.Width -= _slotSpacing.X * 0.5f * slotsH;
+ slotBounds.X += _slotSpacing.X * 0.5f;
+ }
+ }
+
var c = _children[i++];
c.Bounds = slotBounds;
}