diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-11-14 11:33:39 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-11-14 11:33:39 -0300 |
commit | 7c00f0599e56137523f2ec6669b980d11423e9a0 (patch) | |
tree | 23a4823a966d39ece8acee588a860d257805facb | |
parent | 4d88721e625b300608f54b14e7dd150411e5497b (diff) |
Add proper warnings when attempting to create a ViewporTexture in a resource that is not fit for it. Closes #16006.
-rw-r--r-- | editor/editor_properties.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b68ec97406..9c1d22f6ec 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<Resource>(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<StringName> 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"); |