How to change material without creating a new material instance?

How to change material without creating a new material instance?

Using renderer.material = myOtherMaterial; will create a new instance of myOtherMaterial

I need it to be the same instance so GPU instancing will work.

You have to use sharedMaterial / sharedMaterials instead of material / materials.

I am facing the same issue, and as far as I can see .material and .shared material call the same function inside the setter in the Renderer class. The only solution I have found is to treat it as setting a material on a renderer will always create a new instance. Perhaps this is a bug?