Merge pull request #40908 from Chaosus/vs_fix_preview_3.2

[3.2] Fix port previews for uniforms in visual shaders
This commit is contained in:
Rémi Verschelde 2021-02-02 16:58:19 +01:00 committed by GitHub
commit 25bc4891d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3367,11 +3367,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);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {