|
Kind of hard to word, but I have a shader and I want to change the float value using another script. When I change the float value of a specific property I want all materials using the shader to change also. How can I do this? I have looked through the documentation and found nothing. This is as close as I have gotten, but it only fades the material assigned, not all materials using that shader. In java
(comments are locked)
|
Object [] renderers = GameObject.FindObjectsOfType(typeof(Renderer));
int i_max = renderers.Length;
for (int i = 0; i < i_max; i++)
{
Material[] materials = ((Renderer)renderers[i]).materials;
int j_max = materials.Length;
for (int j = 0; j < j_max; j++)
{
if (materials[i].shader.name == "YOUR SHADER")
{
materials[i].SetFloat("VALUE NAME", 1.0f);
}
}
}
Thank you for this, is it java or C#. I forgot to state that it was in java, my apologies, hopefully it is.
Aug 10 '12 at 02:45 AM
BHS
it's C#. i think it is not so hard to translate it to JS if you write in JS 8)
Aug 10 '12 at 11:57 PM
ScroodgeM
(comments are locked)
|
