From 607859c19602d257d9bfa5cd496294e3ad8048c5 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 26 Feb 2024 12:06:06 +0100 Subject: [PATCH] Fix UI Control selection bounds drawing to handle rotations #2067 --- Source/Editor/Windows/GameWindow.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index 9368a30fd..29c8c8318 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -856,7 +856,13 @@ namespace FlaxEditor.Windows var options = Editor.Options.Options.Visual; var control = controlActor.Control; var bounds = control.EditorBounds; - bounds = Rectangle.FromPoints(control.PointToParent(_viewport, bounds.Location), control.PointToParent(_viewport, bounds.Size)); + var p1 = control.PointToParent(_viewport, bounds.UpperLeft); + var p2 = control.PointToParent(_viewport, bounds.UpperRight); + var p3 = control.PointToParent(_viewport, bounds.BottomLeft); + var p4 = control.PointToParent(_viewport, bounds.BottomRight); + var min = Float2.Min(Float2.Min(p1, p2), Float2.Min(p3, p4)); + var max = Float2.Max(Float2.Max(p1, p2), Float2.Max(p3, p4)); + bounds = new Rectangle(min, Float2.Max(max - min, Float2.Zero)); Render2D.DrawRectangle(bounds, options.SelectionOutlineColor0, options.UISelectionOutlineSize); } }