Merge pull request #73082 from aaronfranke/check-canvas-item

Check for CanvasItem instead of Control and Node2D
This commit is contained in:
Rémi Verschelde 2023-02-11 14:35:54 +01:00
commit 7bcd9a1049
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 3 additions and 3 deletions

View File

@ -3685,7 +3685,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
Node *editor_node = SceneTreeDock::get_singleton()->get_tree_editor()->get_selected(); Node *editor_node = SceneTreeDock::get_singleton()->get_tree_editor()->get_selected();
editor_node = editor_node == nullptr ? get_edited_scene() : editor_node; editor_node = editor_node == nullptr ? get_edited_scene() : editor_node;
if (Object::cast_to<Node2D>(editor_node) || Object::cast_to<Control>(editor_node)) { if (Object::cast_to<CanvasItem>(editor_node)) {
editor_select(EDITOR_2D); editor_select(EDITOR_2D);
} else if (Object::cast_to<Node3D>(editor_node)) { } else if (Object::cast_to<Node3D>(editor_node)) {
editor_select(EDITOR_3D); editor_select(EDITOR_3D);

View File

@ -4805,8 +4805,8 @@ void TileSetScenesCollectionSource::set_scene_tile_scene(int p_id, Ref<PackedSce
scene_state = scene_state->get_base_scene_state(); scene_state = scene_state->get_base_scene_state();
} }
ERR_FAIL_COND_MSG(type.is_empty(), vformat("Invalid PackedScene for TileSetScenesCollectionSource: %s. Could not get the type of the root node.", p_packed_scene->get_path())); ERR_FAIL_COND_MSG(type.is_empty(), vformat("Invalid PackedScene for TileSetScenesCollectionSource: %s. Could not get the type of the root node.", p_packed_scene->get_path()));
bool extends_correct_class = ClassDB::is_parent_class(type, "Control") || ClassDB::is_parent_class(type, "Node2D"); bool extends_correct_class = ClassDB::is_parent_class(type, "CanvasItem");
ERR_FAIL_COND_MSG(!extends_correct_class, vformat("Invalid PackedScene for TileSetScenesCollectionSource: %s. Root node should extend Control or Node2D. Found %s instead.", p_packed_scene->get_path(), type)); ERR_FAIL_COND_MSG(!extends_correct_class, vformat("Invalid PackedScene for TileSetScenesCollectionSource: %s. Root node should extend CanvasItem. Found %s instead.", p_packed_scene->get_path(), type));
scenes[p_id].scene = p_packed_scene; scenes[p_id].scene = p_packed_scene;
} else { } else {