How to tell if a material is based on SpatialMaterial or ShaderMaterial in code?
Asked Answered
P

2

0

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.

Parfleche answered 12/2, 2023 at 15:5 Comment(0)
L
0

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.

License answered 12/2, 2023 at 16:19 Comment(0)
P
0

Thank you very much. That's a good solution.

Parfleche answered 13/2, 2023 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.