Hi!
I wanted to ask this to see if it was possible!
Is it possible to get the material that is displayed on a face?
For example, I have a mesh with two materials. If I 'shoot' the mesh, can I see what material was assigned to that face?
Thanks,
-Aj
Hi!
I wanted to ask this to see if it was possible!
Is it possible to get the material that is displayed on a face?
For example, I have a mesh with two materials. If I 'shoot' the mesh, can I see what material was assigned to that face?
Thanks,
-Aj
If 'shoot' the mesh means colliding with the mesh (detected by OnCollisionEnter or a Physics.Raycast) you can access the component(s) like this:
Graphics material used by the renderer:
collider.renderer.material
The Physics material is also available:
collider.material
AJ did you ever get this to work. I'm trying to cast a ray against an object and return the material that is under the hitpoint. I can get the list of materials associated with the collider and of course the main/first material in the objects material list but not the material under the hitpoint.
– Kevin_AmbrusterThat worked perfectly! Thanks for the heads up, saved us some time in having to split up all of our multiple material objects into separate objects.
– Kevin_Ambruster