Slow flood fill of sprite c#
Hey,
I want to implement a slow (over N seconds) flood fill of a sprite over time. I say flood fill as it's the best term I could find to fit, but essentially I want to colour a random sprite from an X/Y location, spreading out the colour from that point over a time period. I do not need to check the colour underneath or to fill only parts of the sprite. This would change any sprite, fully to a given colour (tinting would be fine) over a period of time.
I have tried doing this pixel by pixel, and it works, but it's slower than I'd like and I have to believe there is a better way.
Any pointers you could give me would be greatly appreciated.
Thanks
Answer by TBruce · May 02, 2016 at 01:27 AM
Check out this free asset on the asset store Bitmap Drawing API. It does have flood fill capabilities and you can even modify the code to slow down the rate at which a texture is filled. Of course it was created with Unity 4.3.4 but you should not have to much of a problem making it work with Unity 5.
That asset seems like it will be very useful, similar to the approach I'm already taking. How would I make the method execute over time? Would I just keep track of how far it has gotten and run it again with new variables to tell it to continue? Or is there a way to tell a method to run to completion over a period of time?
What I would do is take the code that does the fill and place it in a Coroutine that does the fill over time until it is done.