Changing a float4 value of a shader via c# script

hello, how can i change the values of a float4 via c# from a script

sample code (not wortking)

public Renderer rend;

void Start(){
rend.material.shader = Shader.Find(MyShaderObject");

rend.material…then here is where it does not work
//the variable is a vector 4 called “_MyCustomFloat4” and is in the shader

}

help please :frowning:

rend.material.SetVector("_MyCustomFloat4", new Vector4(1f, 1f, 1f, 1f));

Please be aware that you’re creating a new instance of the material and setting properties on that reference by accessing the “rend.material” property. If you’d rather set the property without creating a new instance, use “rend.sharedMaterial” instead.

Material mat = rend.sharedMaterial;
mat.SetVector("_MyCustomFloat4", new Vector4(1f, 1f, 1f, 1f));

Thanks This Helped Me Lot