From 3e1e01b7abca396345d3db7d1fd0607ef8935a95 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Thu, 26 Nov 2020 14:25:35 +0300 Subject: Added extra warning to VisualShaderNodeTexture + fix warning appearing --- scene/resources/visual_shader_nodes.cpp | 15 +++++++++++++++ scene/resources/visual_shader_nodes.h | 1 + 2 files changed, 16 insertions(+) (limited to 'scene/resources') diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 704d1b2ea8..a3358ea8c7 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -724,6 +724,10 @@ Vector VisualShaderNodeTexture::get_editable_properties() const { } String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + if (source == SOURCE_TEXTURE) { return String(); // all good } @@ -980,6 +984,10 @@ void VisualShaderNodeSample3D::_bind_methods() { } String VisualShaderNodeSample3D::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + if (source == SOURCE_TEXTURE) { return String(); // all good } @@ -1276,6 +1284,13 @@ Vector VisualShaderNodeCubemap::get_editable_properties() const { return props; } +String VisualShaderNodeCubemap::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + return String(); +} + void VisualShaderNodeCubemap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source); ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source); diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index d4d6540baf..4b39c76388 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -448,6 +448,7 @@ public: TextureType get_texture_type() const; virtual Vector get_editable_properties() const override; + virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override; VisualShaderNodeCubemap(); }; -- cgit v1.2.3