1
votes

how to change the shader`s custom value by code? e.g.

transform.collider.material.MyShader.CustomValue = 2

(I know its wrong,just like this) shader code:

Properties {
    _Value  ("CustomValue", range (0,128)) = 10
}

I want to use C# to cotntrol the "CusomValue",How to code? Use

renderer.material.SetFloat("_Value", newValue);

can do it!thx!

1

1 Answers

2
votes

Use the Material methods. For example:

 renderer.material.SetFloat("_Value", newValue);