reaching collider material name

Hello,
I’m trying to make a script that can reference a game object’s collider (any kind) and let me reference the name of the physic material. I’m not sure if this will work, but what I want is to have several specific physic material names, and use this script to reference the object and let me get the material name for use elsewhere. I’m sorry if this isn’t much detail to go on, but I am just learning C# and am just happy to learn anything that gets me closer to my goals. Thanks

something like

gameobject.GetComponent<Collider>().sharedMaterial.name;

all types of collider (MeshCollider, BoxCollider etc.) inherit from “Collider”.

Big time thanks for the help!

So what is the difference between sharedMaterial.name and material.name.
sharedMaterial gives me an Object reference not set to an instance error, and material gives me an answer of “instance” in the debug logger.

found out that was because I had 2 different colliders on an object with only 1 material assigned

sharedMaterial applies to all instances of that material, so altering it on one object alters all the others using it
material applies to only the instance of the material on this object

if the object has a sharedMaterial and you alter the material it’s gets it’s own instance and breaks the linkage.