From 429f24e6656cd5752e7d9964c4749b1d65cfd45b Mon Sep 17 00:00:00 2001 From: ilyabelow Date: Mon, 4 Dec 2023 00:52:45 +0400 Subject: [PATCH] Add a specific error when creating a ViewportTexture in a Texture2D node in a Visual Shader --- editor/editor_properties.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 2d35d4e9ace..e2b55e1add9 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -56,6 +56,7 @@ #include "scene/resources/font.h" #include "scene/resources/mesh.h" #include "scene/resources/packed_scene.h" +#include "scene/resources/visual_shader_nodes.h" ///////////////////// Nil ///////////////////////// @@ -3196,6 +3197,13 @@ void EditorPropertyResource::_resource_changed(const Ref &p_resource) Ref vpt = p_resource; if (vpt.is_valid()) { r = Object::cast_to(get_edited_object()); + if (Object::cast_to(r)) { + EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture in a Texture2D node because the texture will not be bound to a scene.\nUse a Texture2DParameter node instead and set the texture in the \"Shader Parameters\" tab.")); + emit_changed(get_edited_property(), Ref()); + update_property(); + return; + } + 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.")); emit_changed(get_edited_property(), Ref());