Add tint to a partially transparent sprite
For the sake of simplicity I have this (ugly) png texture.
During runtime I want to add a red tint or shade to this image so that it becomes:
Googling and searching these forums I found that I should be using SpriteRenderer.Color to achieve this so i tried this:
sprGameObj.AddComponent<SpriteRenderer>();
SpriteRenderer sprRenderer = sprGameObj.GetComponent<SpriteRenderer>();
sprRenderer.sprite = newSprite;
sprRenderer.color = new Color32(200, 3, 3, 255);
That however only resulted in this: http://i.imgur.com/R58KwgS.png (not allowed to post any more images in question).
So how do I achieve this?
Well if your image is a UI element (sprite), then you could duplicate that image, and then change the color value to (200, 3, 3, 100). $$anonymous$$eep in $$anonymous$$d your alpha channel in the example you provided is 255, which is no transparency. You may want it to be lower like 100. Is that the problem?
This is what it looks like with (200, 3, 3, 100)
. It makes the entire thing black, and then adds transparency. Could you possibly post a complete sample, maybe it's something Im not understanding correctly.
Your answer

Follow this Question
Related Questions
How do I create sprites and animate ? 0 Answers
In-game asset creation resolution 1 Answer
Sprite Occlusion with Stencil Buffer for Surface Shader? 0 Answers
Weird black lines appearing on Unity 5.4 0 Answers
[Normal Map on 2D Graphics] I NEED HELP! 0 Answers