From 3bbbedc144442026708200c7c4d95b8a90572f19 Mon Sep 17 00:00:00 2001 From: Yuri Rubinsky Date: Thu, 20 Jun 2024 13:37:16 +0300 Subject: [PATCH] Fix visual shader not being updated when switching tabs --- editor/plugins/shader_editor_plugin.cpp | 5 +++++ editor/plugins/visual_shader_editor_plugin.cpp | 6 ++++++ editor/plugins/visual_shader_editor_plugin.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index a8daec7ccbf..d7b88511d9a 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -365,6 +365,11 @@ void ShaderEditorPlugin::_shader_selected(int p_index) { if (edited_shaders[p_index].shader_editor) { edited_shaders[p_index].shader_editor->validate_script(); } + + if (edited_shaders[p_index].visual_shader_editor) { + edited_shaders[p_index].visual_shader_editor->validate_script(); + } + shader_tabs->set_current_tab(p_index); shader_list->select(p_index); } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index cc4466a74ba..3f6927c02a7 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1545,6 +1545,12 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { } } +void VisualShaderEditor::validate_script() { + if (visual_shader.is_valid()) { + _update_nodes(); + } +} + void VisualShaderEditor::add_plugin(const Ref &p_plugin) { if (plugins.has(p_plugin)) { return; diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index ee2bf605d94..a9826fd6178 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -612,6 +612,8 @@ public: void edit(VisualShader *p_visual_shader); Ref get_visual_shader() const { return visual_shader; } + void validate_script(); + VisualShaderEditor(); };