I want to create a scratch-card-like effect in new Unity UI's new Image tag. I know it's possible with setPixels
, but that's prohibitively expensive on mobile devices.
Something like this:
I'd like the user to be able to drag on any part of the image to "scratch off" the top layer and reveal the content underneath it.
How can I do this?
Answer
I have done something similar to this in the past.
My solution to this would be to make use of Unity's new UI Mask and a Render Texture.
When the player touches the screen you would draw a circular sprite at that location and render it to a texture. You would then use this texture for the mask. Over time these sprites will reveal more and more of the image giving you the effect you are after without having to go down the SetPixels route.
This is a similar question that was asked which has a load of good links on it if you don't mind that it's XNA/C# but the concepts are the same.
No comments:
Post a Comment