diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index 6a9a0e065318..96e5bd878dc8 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -57,27 +57,6 @@ Node *SceneTreeEditor::get_scene_node() const { return get_tree()->get_edited_scene_root(); } -PackedStringArray SceneTreeEditor::_get_node_configuration_warnings(Node *p_node) { - PackedStringArray warnings = p_node->get_configuration_warnings(); - if (p_node == get_scene_node()) { - Node2D *node_2d = Object::cast_to(p_node); - if (node_2d) { - // Note: Warn for Node2D but not all CanvasItems, don't warn for Control nodes. - // Control nodes may have reasons to use a transformed root node like anchors. - if (!node_2d->get_transform().is_equal_approx(Transform2D())) { - warnings.append(TTR("The root node of a scene is recommended to not be transformed, since instances of the scene will usually override this. Reset the transform and reload the scene to remove this warning.")); - } - } - Node3D *node_3d = Object::cast_to(p_node); - if (node_3d) { - if (!node_3d->get_transform().is_equal_approx(Transform3D())) { - warnings.append(TTR("The root node of a scene is recommended to not be transformed, since instances of the scene will usually override this. Reset the transform and reload the scene to remove this warning.")); - } - } - } - return warnings; -} - void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) { if (p_button != MouseButton::LEFT) { return; diff --git a/editor/gui/scene_tree_editor.h b/editor/gui/scene_tree_editor.h index ab962b08bf22..faee56059b7b 100644 --- a/editor/gui/scene_tree_editor.h +++ b/editor/gui/scene_tree_editor.h @@ -135,7 +135,6 @@ class SceneTreeEditor : public Control { void _compute_hash(Node *p_node, uint64_t &hash); void _reset(); - PackedStringArray _get_node_configuration_warnings(Node *p_node); void _update_node_path(Node *p_node, bool p_recursive = true); void _update_node_subtree(Node *p_node, TreeItem *p_parent, bool p_force = false); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 4c0f877f2e7f..7643428c3350 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -425,6 +425,22 @@ Point2 Node2D::to_global(Point2 p_local) const { return get_global_transform().xform(p_local); } +#ifdef TOOLS_ENABLED +Vector Node2D::get_configuration_info() const { + Vector infos = CanvasItem::get_configuration_info(); + + // Note: Warn for Node2D but not all CanvasItems, don't warn for Control nodes. + // Control nodes may have reasons to use a transformed root node like anchors. + if (!get_transform().is_equal_approx(Transform2D())) { + CONFIG_WARNING_P( + TTR("The root node of a scene is recommended to not be transformed, since instances of the scene will usually override this. Reset the transform to remove this warning."), + "transform"); + } + + return infos; +} +#endif + void Node2D::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_ENTER_TREE: { diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index de46dbd7d67e..b066698def67 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -117,6 +117,10 @@ class Node2D : public CanvasItem { Transform2D get_transform() const override; +#ifdef TOOLS_ENABLED + Vector get_configuration_info() const override; +#endif + Node2D() {} }; diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 1efa1d9457b2..8e85e0652fd3 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -1161,6 +1161,20 @@ NodePath Node3D::get_visibility_parent() const { return visibility_parent_path; } +#ifdef TOOLS_ENABLED +Vector Node3D::get_configuration_info() const { + Vector infos = Node::get_configuration_info(); + + if (!get_transform().is_equal_approx(Transform3D())) { + CONFIG_WARNING_P( + TTR("The root node of a scene is recommended to not be transformed, since instances of the scene will usually override this. Reset the transform to remove this warning."), + "transform"); + } + + return infos; +} +#endif + void Node3D::_validate_property(PropertyInfo &p_property) const { if (data.rotation_edit_mode != ROTATION_EDIT_MODE_BASIS && p_property.name == "basis") { p_property.usage = 0; diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index 20288fad3a6b..93f0d77f8d88 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -300,6 +300,10 @@ class Node3D : public Node { void set_visibility_parent(const NodePath &p_path); NodePath get_visibility_parent() const; +#ifdef TOOLS_ENABLED + Vector get_configuration_info() const override; +#endif + Node3D(); ~Node3D(); };