MaterialPropertyBlock Equivalent for Projectors?

Hi guys! This is my first post here ever since I started with Unity. I’m really thankful for the strong community that holds Unity up; I’ve learned so much just from lurking around the forums.

So now I’m trying to create a game that makes use of projectors quite heavily(Projectors get spawned programmatically and the like). The projectors all use the same shader and material. What I want to do is individually change some properties of the shader through script. I know about MaterialPropertyBlock and how awesome it would’ve been if Projectors had renderers.

Is there any workaround for this?

TL;DR - I want to make some projectors project slightly different stuff using code :3

You will want to create your own instance of the material, to modify, so other objects using that material are not affected by changes to your instance the material. You can have multiple objects, configured with the same (starting) material, and the below code will create a custom material for it’self(each), and use THAT one in the renderer.

public class UniqueMaterialModifier : MonoBehaviour {

    public MeshRenderer rendererToModify; // whatever material this is using, is our "starting" Material
    Material customMaterial; //stores our own custom instance of the starting meterial.
    public Color overrideColor;  //we want to make the material use this color, when drawing the "rendererToModify"
    public Texture2D overrideTexture;//we want to make the material use this texture, when drawing the "rendererToModify"

	// Use this for initialization
	void Start () {
        customMaterial = new Material(rendererToModify.material); //create our own instance
        customMaterial.color = overrideColor; //change only OUR instance of the materal to use this color. (this will NOT create another instance of the material!)
        customMaterial.mainTexture = overrideTexture;
        rendererToModify.material = customMaterial;  //set the renderer to draw using our customMaterial.
    }


    private void Update()
    {
        customMaterial.color = new Color(Random.Range(0.0f,1.0f), customMaterial.color.g, customMaterial.color.b);// just to make sure it works in update, this will make the "redness" of the object flicker randomy).

    }
}