From 5e79e02d0fbe8b19b06871a6d378669cd193dc67 Mon Sep 17 00:00:00 2001 From: RedMser Date: Fri, 10 May 2024 18:50:17 +0200 Subject: [PATCH] Fix Control resizing wrongly after "change type" in editor --- editor/scene_tree_dock.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c2d6acd140c0..53145c3450ee 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2907,6 +2907,13 @@ void SceneTreeDock::_replace_node(Node *p_node, Node *p_by_node, bool p_keep_pro } } + // HACK: Remember size of anchored control. + Control *old_control = Object::cast_to(oldnode); + Size2 size; + if (old_control) { + size = old_control->get_size(); + } + String newname = oldnode->get_name(); List to_erase; @@ -2917,6 +2924,12 @@ void SceneTreeDock::_replace_node(Node *p_node, Node *p_by_node, bool p_keep_pro } oldnode->replace_by(newnode, true); + // Re-apply size of anchored control. + Control *new_control = Object::cast_to(newnode); + if (old_control && new_control) { + new_control->set_size(size); + } + //small hack to make collisionshapes and other kind of nodes to work for (int i = 0; i < newnode->get_child_count(); i++) { Node *c = newnode->get_child(i);