Color Sprite

Hello everyone, I would like to learn how to change the color of the sprite (eg red ball comes on the green tile itself becomes green) sorry for my english

Try this…

(Assuming you are using a SpriteRenderer component on the object you want to change color…)

GetComponent<SpriteRenderer>().color = Color.green;
1 Like

What is the diference between?

GetComponent().material.color = Color.green;

and

GetComponent().color = Color.green;

Thanks

Changing material color breaks batching and applies to all renderers using that material.
Changing SpriteRenderer color influences only that instance and does not break batching because it is stored per vertex.

In the shader both colors are multiplied.