unity set sprite rendere color in code code example
Example 1: how to change the color of a sprite in unity
//option 1
GetComponent<spriteRenderer>().color = Color.red
//option 2
sprite.color = new Color (R, G, B, A);
Example 2: change sprite color unity
sprite.color = new Color (1, 0, 0, 1);