But this compares false even when I know it to be true. Outputting the name of the shared material shows that it is an instance of the material. How can I get the original in order to compare them?
Given you have a material in your project called “MyMaterial” it might be on your actual gameObject a “MyMaterial (Instance)”. Because you assigned other textures, colors or so.
Now do something like this:
String baseMaterialName = myBaseMaterial.name;
String assignedMaterialName = myRenderer.sharedMaterial.name;
if (assignedMaterialName.Contains(baseMaterialName) ) {
// here is your Match
}