know object behind another object is fully visible

384 views Asked by At

I have developed scratch card effect.I am stuck at logic of how can I know object got visible which is behind the scratch card image? So that I can show reward screen.

PS: with modifications in this link I able to work this scratch card effect in uGUI.

enter image description here

1

There are 1 answers

0
Arttu Peltonen On

There are many ways you could go about this. Assuming you know the dimensions of the red "target image" that the user is trying to uncover, you could take a fixed number of samples from the area that the target is under. Once, say, 80% of those samples are transparent (i.e. the target is visible at those positions), you can consider the object visible and show the reward screen.

You can use GetPixel to get the individual samples from the scratch texture.