From 3223747d0d2d35afa1e2e422689090d20e81654d Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Thu, 26 Nov 2020 19:14:33 +0300 Subject: [PATCH] [3.2] Added extra warning to texture nodes in visual shader --- scene/resources/visual_shader_nodes.cpp | 11 +++++++++++ scene/resources/visual_shader_nodes.h | 1 + 2 files changed, 12 insertions(+) diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 3adc7e9ea408..7d1450478e6c 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -681,6 +681,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 } @@ -907,6 +911,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); diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 9a270ce4f799..8c9b8c2dbdbe 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -303,6 +303,7 @@ class VisualShaderNodeCubeMap : public VisualShaderNode { TextureType get_texture_type() const; virtual Vector get_editable_properties() const; + virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const; VisualShaderNodeCubeMap(); };