Search Unity

Programmatically coloring sprites

Discussion in '2D' started by dccoo, May 29, 2017.

  1. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    161
    I have this tree sprite:
    upload_2017-5-28_23-46-32.png
    I'd like to create a script that makes the green parts change their colors for another three colors.

    I don't know how to start, as I can't run a for loop without breaking the game and I read that if you change the color of the sprite, you change the color of all trees that use that sprite, and I don't want that.

    What approach should I use to do this (in Start() if possible) ? Thank you !!!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,432
    dccoo and LiterallyJeff like this.