'TestMaterial' is not a member of 'UnityEngine.Renderer'.

Hi
I’m new to this so this may be a daft question. I have created a unique shader called Testshader with a color parameter called TestColor in it. I have applied this test shader to the material called TestMaterial. I have now written a very small Java script to change the value of the parameter TestColor but for some reason it throws up this error message when I try and run the game:

Assets/ShaderScript.js(5,10): BCE0019: ‘TestMaterial’ is not a member of ‘UnityEngine.Renderer’.

I have no idea what this means and I can’t find anything online about it (which makes me wonder if I’m doing something really stupid, LOL!)

Here’s the code I’m using in the Java script:

function Update () {
renderer.TestMaterial.SetColor(“_TestColor”, Color.red) = 0.5;
}

I’m hoping someone can help me out :slight_smile:

Thankyou in advance

                 Immy

Bongoboo Games

Change TestMaterial to material or sharedMaterial, depending what you’re trying

If there are multiple materials, you can also use materials to get the array of materials

Hi Mike!
That’s excellent thanks :slight_smile: I understand now how it works, but your answer has clarified it perfectly.

thanks again!
Immy