From ee3b51250ae1ddbb45df396e863489cbe2af9499 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Tue, 2 Feb 2021 13:41:05 +0300 Subject: Fix port previews for uniforms in visual shaders --- editor/plugins/visual_shader_editor_plugin.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index ea6afe7f84..5061067ded 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -4473,10 +4473,17 @@ void VisualShaderNodePortPreview::_shader_changed() { for (int i = EditorNode::get_singleton()->get_editor_history()->get_path_size() - 1; i >= 0; i--) { Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(i)); + ShaderMaterial *src_mat; if (!object) { continue; } - ShaderMaterial *src_mat = Object::cast_to(object); + if (object->has_method("get_material_override")) { // trying getting material from MeshInstance + src_mat = Object::cast_to(object->call("get_material_override")); + } else if (object->has_method("get_material")) { // from CanvasItem/Node2D + src_mat = Object::cast_to(object->call("get_material")); + } else { + src_mat = Object::cast_to(object); + } if (src_mat && src_mat->get_shader().is_valid()) { List params; src_mat->get_shader()->get_param_list(¶ms); -- cgit v1.2.3