From 8b4f8de9888b72aa5b4504d04bb3314f22b8a651 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 12 Mar 2026 15:27:31 +0100 Subject: [PATCH] Fix `Control.LocalLocation` to use parent control `GetDesireClientArea` rather than `Bounds` #3889 --- Source/Engine/UI/GUI/Control.Bounds.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs index 62bffd6f7..079530c50 100644 --- a/Source/Engine/UI/GUI/Control.Bounds.cs +++ b/Source/Engine/UI/GUI/Control.Bounds.cs @@ -166,8 +166,26 @@ namespace FlaxEngine.GUI [NoSerialize, HideInEditor] public Float2 LocalLocation { - get => _bounds.Location - (_parent != null ? _parent._bounds.Size * (_anchorMax + _anchorMin) * 0.5f : Float2.Zero) + _bounds.Size * _pivot; - set => Bounds = new Rectangle(value + (_parent != null ? _parent.Bounds.Size * (_anchorMax + _anchorMin) * 0.5f : Float2.Zero) - _bounds.Size * _pivot, _bounds.Size); + get + { + var anchor = Float2.Zero; + if (_parent != null) + { + _parent.GetDesireClientArea(out var parentBounds); + anchor = parentBounds.Location + parentBounds.Size * (_anchorMin + _anchorMax) * 0.5f; + } + return _bounds.Location - anchor + _bounds.Size * _pivot; + } + set + { + var anchor = Float2.Zero; + if (_parent != null) + { + _parent.GetDesireClientArea(out var parentBounds); + anchor = parentBounds.Location + parentBounds.Size * (_anchorMin + _anchorMax) * 0.5f; + } + Bounds = new Rectangle(value + anchor - _bounds.Size * _pivot, _bounds.Size); + } } ///