Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
8 years ago
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?
13.4k 10 10 gold badges 54 54 silver badges 82 82 bronze badges
May 25, 2015 at 13:39
530 5 5 silver badges 21 21 bronze badges
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.
May 28, 2015 at 10:59
Assuming no setPixel,
make a "single dirt bitmap"(1). Place a bunch of texture2d objects(2) (using image(1)) over the "card" and make them disappear when you move over them.
You can define properties on each (2) , so that one Texture object may take two (or more) scratch to disappear.
May 28, 2015 at 10:30
log in to answer this question.
Not the answer you're looking for? Browse other questions tagged
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only