Search Unity

Changing color of texture from script

Discussion in 'Scripting' started by Darloc, Jun 19, 2011.

  1. Darloc

    Darloc

    Joined:
    Feb 16, 2011
    Posts:
    167
    Is there a way to modify the rgb values of a texture from a script or do I need to make several different textures and just assign a different one depending on the values?

    Thanks
     
  2. callahan.44

    callahan.44

    Joined:
    Jan 9, 2010
    Posts:
    694
    There is the option of using the tint colour in the GUI or Shader variables, but it would be easier to just swap the texture with another.
    SetPixel is also available but may be too much work.

    Without knowing the effect you are aiming for it's difficult to recommend.
     
  3. Darloc

    Darloc

    Joined:
    Feb 16, 2011
    Posts:
    167
    I am am making an evolution type project where the child inherits from both parents plus a mutation factor, so I would like something like a red parent and a blue parent make a purple child or something or maybe (if I can find a way to do it) one with spots and one without have a chance for a little spots medium a lot or none so I am guessing this kind of stuff I would just need to make hundreds of different textures? or how does setPixel work?
     
  4. callahan.44

    callahan.44

    Joined:
    Jan 9, 2010
    Posts:
    694
  5. Darloc

    Darloc

    Joined:
    Feb 16, 2011
    Posts:
    167
    no I would do it once when they were created and create genetic traits that determine stripes spots etc. that would be great, thanks man