- Home /
How to change color of all the pixels from a sprite that have a given color value?
Hi, I have a sprite and I want - at run time- to change all the blue pixels of that sprite to let's say yellow. Just the blue one, something like: "Sprite.ReplacePixelColor(Blue, Yellow) " is this posible?
For a more flexible approach, try implementing a palette system for your sprites, such as this one here:
Answer by carlqwe · Apr 22, 2016 at 10:13 AM
I dont really think that this is possible, the easiest is the change the graphics or the sprite in Script. Tho let me know if its possible.
TO change to sprite do something like this; public SpriteRenderer ImageComponent; public Sprite YellowSprite; public Sprite BlueSprite;
void Start ()
{
ImageComponent = GetComponent<SpriteRenderer>();
}
void Update ()
{
ImageComponent.Sprite = BlueSprite;
}
UPDATE:
I found something intressting if you dont wanna use the option above. Here i found something intressting. I've never used this before so it might not be compleatly right, use the same getComponent, and then use
ImageComponent.Color = (255, 255, 0);
//Or Something like that.
Hope it works out fine! ~carlqwe