Projector.material = sharedMaterial ?

I’m playing with projectors, and to change the texture and color by script, the only way I found is use projector.material :

projector.material.SetTexture ("_Texture", myTexture);
projector.material.SetColor ("_Color", myColor);

Unfortunately, it changes all the projectors of my scene using the material like I was using the propertie “sharedMaterial” of a renderer.

Is there any other way to solve that than using one material per projector ?

Well I made my own system. A Start :

Material newMaterial = new Material(projector.material);
projector.material = newMaterial ;

It’s probably not really efficient but it works :slight_smile:

I have created extension for this change.

/// <summary>
/// Projector material is like renderer.shaderMaterial. if you need to change instance, use this extension.
/// </summary>
/// <param name="projector"></param>
/// <param name="color"></param>
/// <param name="keepAlpha"></param>
public static void ChangeColor(this Projector projector, Color color, bool keepAlpha = true)
	var mat = new Material(projector.material);
	if (!"(Instance)")) += " (Instance)";
	if (keepAlpha)
		color.a = mat.color.a;
	mat.color = color;
	projector.material = mat;