So I have different types of materials in my project.
I need to distinguish them in code when setting the uniforms.
For example: material.metallic only works for SpatialMaterials.
It would be material.set_shader_parameter("metallic ", 1.0) for ShaderMaterials with the same uniform name.
I couldn't find any type attribute to tell them apart.
How to tell if a material is based on SpatialMaterial or ShaderMaterial in code?
Asked Answered
I haven't tried this but since almost everything inherits from Object class(directly or indirectly) which implements a has_method() method, you could probably use that to check for set_shader_parameter method...
There's also the get_class() method, is_class() method, and plenty of others that might help.
Thank you very much. That's a good solution.
© 2022 - 2024 — McMap. All rights reserved.