- Home /
Change shader properties during rungtime
I have shader on a Fog of War Plane. The Shader has a FogRadius property so that I reveal a circle with radius=FogRadius. I want each unit to have a different FogRadius value so that some units reveal more than others. However, it seems that the FogRadius is only changed once. The starting value of FogRadius is 4. The Units have the following radius: 1, 5 and 10. However, during runtime the FogRadius is always 5 so each unit reveals with the same radius.
if (Physics.Raycast (rayToPlayerPos, out hit, 1000, layermask)) {
FogOfWarPlane.GetComponent<Renderer> ().material.SetFloat ("_FogRadius", radius);
FogOfWarPlane.GetComponent<Renderer> ().material.SetVector ("_Player" + Number.ToString () + "_Pos", hit.point);
}
Is my logic flawed? Thanks in advance for your help.
Answer by ElvishChampion · Jun 09, 2014 at 08:22 PM
Ok I solved it.
Couldn't modify the shader during runtime to make it work. I had to modify the shader so that each of the appertures had its Radius (_FogRadius1, _FogRadius2, _FogRadius3 etc).
Your answer
![](https://koobas.hobune.stream/wayback/20220613142959im_/https://answers.unity.com/themes/thub/images/avi.jpg)