Search Unity

TrailRenderer colors in code

Discussion in 'Scripting' started by besuser, Nov 16, 2007.

  1. besuser

    besuser

    Joined:
    Oct 9, 2007
    Posts:
    292
    Sorry for all the questions, but I'm stumped on this one. The TrailRenderer component has an array of colors that you can customize in the Unity GUI. I would like to customize them in script, but I can't figure out how to do it (as the colors array is apparently not a modifiable field of the class??). For now, I'm only worried about alpha, though having access to the other properties would be nice. I tried to alter the alpha through the material, but when I try to set the material color, I get an error which essentially tells me that the shader doesn't have a "_Color" property. I tried the other common properties (SpecColor, EmissiveColor, etc.) but didn't find anything. I'm using the provided "Particles/Additive" shader.

    Any thoughts on how to access the colors array?
    Alternatively: Any way to view the properties of the shader? (I don't know where to find the shader code source)

    Thanks as always! I really appreciate it!
     
  2. hockeybag

    hockeybag

    Joined:
    Jan 25, 2007
    Posts:
    29
    Try making another material in the color that you need to change to and then material.Lerp to it.

    Alex.
     
  3. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370