From 21b1530cd4172d09653ff72b74f3152afc4024f2 Mon Sep 17 00:00:00 2001 From: limuy Date: Wed, 9 Jul 2025 23:02:07 +0800 Subject: [PATCH] Fix incorrect anchor preset when custom offset is set --- scene/gui/control.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0554ffc5c1..a2613adeb3 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1043,6 +1043,10 @@ int Control::_get_anchors_layout_preset() const { float top = get_anchor(SIDE_TOP); float bottom = get_anchor(SIDE_BOTTOM); + if (get_offset(SIDE_LEFT) != 0.0 || get_offset(SIDE_RIGHT) != 0.0 || get_offset(SIDE_TOP) != 0.0 || get_offset(SIDE_BOTTOM) != 0.0) { + return -1; + } + if (left == (float)ANCHOR_BEGIN && right == (float)ANCHOR_BEGIN && top == (float)ANCHOR_BEGIN && bottom == (float)ANCHOR_BEGIN) { return (int)LayoutPreset::PRESET_TOP_LEFT; }