You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Fix Control resizing wrongly after "change type" in editor
This commit is contained in:
@@ -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<Control>(oldnode);
|
||||||
|
Size2 size;
|
||||||
|
if (old_control) {
|
||||||
|
size = old_control->get_size();
|
||||||
|
}
|
||||||
|
|
||||||
String newname = oldnode->get_name();
|
String newname = oldnode->get_name();
|
||||||
|
|
||||||
List<Node *> to_erase;
|
List<Node *> 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);
|
oldnode->replace_by(newnode, true);
|
||||||
|
|
||||||
|
// Re-apply size of anchored control.
|
||||||
|
Control *new_control = Object::cast_to<Control>(newnode);
|
||||||
|
if (old_control && new_control) {
|
||||||
|
new_control->set_size(size);
|
||||||
|
}
|
||||||
|
|
||||||
//small hack to make collisionshapes and other kind of nodes to work
|
//small hack to make collisionshapes and other kind of nodes to work
|
||||||
for (int i = 0; i < newnode->get_child_count(); i++) {
|
for (int i = 0; i < newnode->get_child_count(); i++) {
|
||||||
Node *c = newnode->get_child(i);
|
Node *c = newnode->get_child(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user