2D Toolkit Forum
2D Toolkit => Support => Topic started by: Lavaflyer on February 04, 2014, 11:44:07 pm
-
How do you set the color of an sprite based on its existing color?
oObject.GetComponent<tk2dSprite>().color += new Color (0,0,60);
that doesnt seem to work but for some reason this does work:
oObject.GetComponent<tk2dSprite>().color = new Color (0,0,60);
but that just turns the sprite blue and I want to simply "mask"/overlay it in a light blue. I have this same problem with text meshes and changing the alpha of a color. Any help is greatly appreciated, thanks!
-
You can't mask or overlay a sprite like that. You will have to modify the shader to do it.
Also, colour is a property - you can't add to it but something like this will work:
oObject.GetComponent<tk2dSprite>().color = oObject.GetComponent<tk2dSprite>().color + new Color32(0,0,60,255);
Also, the range of rgb components in Color is 0..1, not 0..255. If you want 0..255 range, use Color32.