Hi all,
I am using the URP and want to set a material that uses a Shader Graph dissolve shader to a renderer with multiple materials. This is my code:
var dissolveMaterials = new Material[originalMaterials[i].Length];
//Create a new array of materials of the length of the original materials, set all these to dissolve and give them the colour of the original material
for(int j = 0; j < dissolveMaterials.Length; j++)
{
dissolveMaterials[j] = dissolveMaterial;
dissolveMaterials[j].SetColor("Albedo", originalMaterials[i][j].color);
activeMaterials.Add(dissolveMaterials[j]);
}
//Set this new array
rendererList[i].materials = dissolveMaterials;
Where dissolveMaterials is the array with the dissolve shader material I want to set (with different colours).
My strange problem is, that while the materials and their colours are set, only the first material is (Instance), the other is shared… This is a problem, as this means I can’t set individual colours or update the shader clip threshold of the not-Instance materials.
I have tried setting the dissolveMaterial with new or Instantiating it, but this doesn’t help.
Does anyone know why only the first material is an Instance, or how I can get the others to become an Instance?
Thanks in advance!