SetFloat to all materials

Hi,

I’m doing the following:

gameObject.GetComponent(Renderer).material.SetFloat( “_Select”, selected?10.0:0.0 );

but my objects have 2-3 materials on them… and only the first one receives the value
is it possible that all materials receive the SetFloat?

regards,
Peter Wraae Marino

Either loop through a copy of the materials array, and assign the copy back to the renderer, or use SetGlobalFloat, if you need the same thing to happen to all materials.

Also, GetComponent is also a method of Component, so you don’t need gameObject. in there. But that point is kind of moot in this case, due to the .renderer property.

@Jessy,… yep,. found out that there is array… problem solved (and works)

thanks
Peter