UI Image unable to changing materials colour changes all instances

Title says it all, I’ve looked online for multiple solutions.
I’m instantiating a Prefab multiple times for my UI, I’m trying to set the child of this prefabs Image components Materials Colour (what a chain of words), and its resulting in them all being the same colour as the last one instantiated (I believe the entire material colour is being changed).

hair.material.SetColor("_HairColour", hairColour);

I have almost the exact same code working fine for my actual game objects using SpriteRenderers. It seems to be something with the Image component…

I’ve tried forcably making Clones of the material from the material & the shader like so, it does indeed make (Clone)'s but it still acts the same way in both cases…

GetComponent<Image>().material = Instantiate(GetComponent<Image>().material);
Material instance = new Material(shader);
        instance.CopyPropertiesFromMaterial(material);
        GetComponent<Image>().material = Instantiate(instance);

I’m at a loss here, so any assistance would be appreciated!

Are you doing shader / material tricks that prevent you from just changing out the .sprite and/or .color property of the UnityEngine.UI.Image itself?

That is almost always going to be the simplest approach.

Otherwise your issue is (as you intuit) almost certainly a material cloning / reference issue, which is common due to Unity’s aliasing rules.

The reference way to ensure a material is instantiated and unique is to do exactly that explicitly, step at a time, not trying to cram everything into one line.

Material m1 = myImage.material;

Material m2 = new Material( m1);   /// same as instantiate AFAIK

m2.modify-whatever-you-want-here

myOtherImage.material = m2;