Search Unity

control the Tint color of the material

Discussion in 'Scripting' started by raviraj_vdy, May 14, 2009.

  1. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
    Hello there

    Can any body let me know how to control the Tint color of the material which is provided when the material - "shader" is set to "Particles/Additive" Through Scripting ?

    thanx
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Code (csharp):
    1. renderer.material.SetColor ("_TintColor", Color);
     
  3. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
    Thanx it really helped

    there is a slight issue but that is im unable to set the color as per my choice.

    var color = Color.yellow;
    particleTrailRenderer.material.SetColor("_TintColor", color);
    can i pass values to the color function as per my choice of color.
    eg: var color =Color(128,255,225,128);

    but its not helping..........
    thnx
     
  4. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Color values in unity are in the 0-1 range which is why 128,255,225,128 isn't working.
     
    PrasannaSRK07 likes this.
  5. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
    Ok thanx il try it out. :D
     
  6. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,967
    cool! this helped me too!
     
  7. YasanthaPrabath

    YasanthaPrabath

    Joined:
    Jul 2, 2010
    Posts:
    13
    Helped me too
     
  8. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    For this to work obviously the shader needs to have a _TintColor property in the shader. (Which this specific shader has).
     
  9. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    thx!
    worked like a charm
     
  10. chulini

    chulini

    Joined:
    May 18, 2013
    Posts:
    3
    this helped me a lot.
    thanks!
     
  11. Rendang1963

    Rendang1963

    Joined:
    Oct 19, 2009
    Posts:
    8
    same here, that was very helpful.
    many thanks.
     
  12. JColling

    JColling

    Joined:
    Mar 10, 2015
    Posts:
    7
    Hello -

    Sorry for digging up an old thread, but I was wondering if anyone could tell me how to animate the Tint Color's alpha channel? Not the color......Thanks for any help.
     
  13. Sixbraker

    Sixbraker

    Joined:
    May 20, 2017
    Posts:
    8
    you can use
    Color.color = new Color(xxxf/255f, xxxf/255f, xxxf/255f, xxxf/255f)
    rather than using 0 to 1.
     
  14. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    If you want to set colors in 0-255 manner, you may use Color32 instead of Color.