diff --git a/Source/Engine/UI/GUI/Common/Label.cs b/Source/Engine/UI/GUI/Common/Label.cs
index dca68948c..7cb3e4d42 100644
--- a/Source/Engine/UI/GUI/Common/Label.cs
+++ b/Source/Engine/UI/GUI/Common/Label.cs
@@ -337,9 +337,7 @@ namespace FlaxEngine.GUI
size.X = _textSize.X + Margin.Width;
if (_autoHeight)
size.Y = _textSize.Y + Margin.Height;
- var pivotRelative = PivotRelative;
- Size = size;
- PivotRelative = pivotRelative;
+ Resize(ref size);
}
}
}
diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs
index 6054250f8..de2711b25 100644
--- a/Source/Engine/UI/GUI/Control.Bounds.cs
+++ b/Source/Engine/UI/GUI/Control.Bounds.cs
@@ -419,6 +419,19 @@ namespace FlaxEngine.GUI
}
}
+ ///
+ /// Resizes the control based on where the pivot is rather than just the top-left.
+ ///
+ [NoAnimate]
+ public void Resize(ref Float2 value)
+ {
+ if (_bounds.Size.Equals(ref value))
+ return;
+ var bounds = new Rectangle(_bounds.Location, value);
+ bounds.Location += (_bounds.Size - value) * Pivot; // Pivot-relative resizing
+ SetBounds(ref bounds);
+ }
+
///
/// Updates the control cached bounds (based on anchors and offsets).
///
diff --git a/Source/Engine/UI/GUI/Panels/DropPanel.cs b/Source/Engine/UI/GUI/Panels/DropPanel.cs
index e053edd9c..28a1fb8c9 100644
--- a/Source/Engine/UI/GUI/Panels/DropPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/DropPanel.cs
@@ -585,7 +585,8 @@ namespace FlaxEngine.GUI
_cachedHeight = height;
if (_animationProgress >= 1.0f && _isClosed)
y = minHeight;
- Height = Mathf.Max(minHeight, y);
+ var size = new Float2(Width, Mathf.Max(minHeight, y));
+ Resize(ref size);
}
///
diff --git a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
index 1c8e646e3..06d185f2d 100644
--- a/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/HorizontalPanel.cs
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
size.X = left + right;
if (!ControlChildSize)
size.Y = maxHeight;
- Size = size;
+ Resize(ref size);
}
else if (_alignment != TextAlignment.Near && hasAnyLeft)
{
diff --git a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
index aae95bd43..d5c6dfb9f 100644
--- a/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/VerticalPanel.cs
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
size.Y = top + bottom;
if (!ControlChildSize)
size.X = maxWidth;
- Size = size;
+ Resize(ref size);
}
else if (_alignment != TextAlignment.Near && hasAnyTop)
{