Dynamically change Shader property on same gameObject

I have a shader on a gameObject, Lets call it FooShader. In FooShader there is a public property called _fooVal I want to update in real time.

I’ve created a blank C# script on the same gameObject.
My first problem is how do I reference this FooShader script? And then once I have a correct reference change my _fooVal property?

public class ExampleClass : MonoBehaviour {
public Renderer rend;
void Start() {
rend = GetComponent();
rend.material.shader = Shader.Find(“Specular”);//Gets the Shader
}
void Update() {
float shininess = Mathf.PingPong(Time.time, 1.0F);
// rend.material.SetFloat(“_fooVal”, shininess);//Set float assignes the var in the shader
rend.material.SetFloat(“_Shininess”, shininess);//Set float assignes the var in the shader
}
}

Have fun with unity shaders! I know I did… *Rolls eyes

I was not the person who made the question but this code would be very useful for my University Project. Thanks a lot! :smiley: