Hey!
I want to be able to modify the hue and saturation of an animated sprite during runtime. I've looked around a bit, and found a HSV color-struct which will help me out with this. This code works for a Texture2D:
void SetSaturation(float saturation)
{
texture2D = animSpriteTexture;
Color[] pixels = texture2D.GetPixels();
for (int i = 0; i < pixels.Length; i++)
{
HSVColor temp = HSVColor.FromColor(pixels[i]);
temp.s = saturation;
pixels[i] = temp.ToColor();
}
texture2D.SetPixels(pixels);
texture2D.Apply ();
}
So what I'd like to do is to either:
1. Have a script (which probably inherits from tk2dAnimatedSprite) that for every frame can get the current frame's Texture2D at runtime and then run this function.
2. Perhaps get the GameObject's atlas and apply the changes to the whole atlas.
How would I go about this? I want to be able to only modify one GameObjects saturation this way (and let all other GameObjects which have the same AnimLib have their own saturation), so I'm wondering, GameObjects which share the same AnimLib, do they have an unique atlas for their animations or do they all share one?