From 7c00f0599e56137523f2ec6669b980d11423e9a0 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 14 Nov 2018 11:33:39 -0300 Subject: [PATCH] Add proper warnings when attempting to create a ViewporTexture in a resource that is not fit for it. Closes #16006. --- editor/editor_properties.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b68ec97406e..9c1d22f6ecc 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2069,8 +2069,22 @@ void EditorPropertyResource::_menu_option(int p_which) { if (intype == "ViewportTexture") { + Resource *r = Object::cast_to(get_edited_object()); + if (r && r->get_path().is_resource_file()) { + EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene.")); + return; + } + + if (r && !r->is_local_to_scene()) { + EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on this resource because it's not set as local to scene.\nPlease switch on the 'local to scene' property on it (and all resources containing it up to a node).")); + return; + } + if (!scene_tree) { scene_tree = memnew(SceneTreeDialog); + Vector valid_types; + valid_types.push_back("Viewport"); + scene_tree->get_scene_tree()->set_valid_types(valid_types); scene_tree->get_scene_tree()->set_show_enabled_subscene(true); add_child(scene_tree); scene_tree->connect("selected", this, "_viewport_selected");