summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-02 16:58:11 +0100
committerGitHub <noreply@github.com>2021-02-02 16:58:11 +0100
commit9620c1ce61af88212ed5a245742245be0308e96c (patch)
tree6994447887a937a109e108095c2f9eaa9682e3ad
parentea1e26f312c3a03816bc69850e5cd74c353d4bb6 (diff)
parentee3b51250ae1ddbb45df396e863489cbe2af9499 (diff)
Merge pull request #45659 from Chaosus/vs_fix_preview
Fix port previews for uniforms in visual shaders
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp9
1 files changed, 8 insertions, 1 deletions
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<ShaderMaterial>(object);
+ if (object->has_method("get_material_override")) { // trying getting material from MeshInstance
+ src_mat = Object::cast_to<ShaderMaterial>(object->call("get_material_override"));
+ } else if (object->has_method("get_material")) { // from CanvasItem/Node2D
+ src_mat = Object::cast_to<ShaderMaterial>(object->call("get_material"));
+ } else {
+ src_mat = Object::cast_to<ShaderMaterial>(object);
+ }
if (src_mat && src_mat->get_shader().is_valid()) {
List<PropertyInfo> params;
src_mat->get_shader()->get_param_list(&params);