Hello, I want to create game for mobile (android). In this game are two other images (have the same width and height) and the first covers the second. How can I get the effect that when you click on the first one, the clicks place becomes transparent (only this place) and you can see the second image that on stage is located behind the first?
Thanks
Well, it’s not as easy as you might think. You’ll have to dynamically update a texture — see Texture2D.SetPixel.
Or, this is the sort of thing being demonstrated in my PixelSurface demo, which I expected to generate some excitement, but which has so far been met with only chirping crickets. 
I mean just about getting such an effect, doesn’t matter how. So the only way is dynamically update a texture or have you got other ideas?
Nope, that’s the only way (unless there are some special constraints you haven’t mentioned, like the click regions are organized into a grid or some such).
Then what do you think about that solution:
First image (invisible from game start) in background and second (visible from game start) between first image and camera. If click on second image, for example pixel (x,y) get the same pixel from invisible image (in background) then change this pixel on second image. Do you think that should it work? How can I get the value of x and y when touched?
So it is like a puzzle game with the top picture broken into shapes/grids & when you click on a bit of it that bit disappears & you can see a bit of the one under it?
If so why not have the bottom picture as just a normal picture on a plane with the top one (shaped/segmented one) in front of it. When you click on one of the blocks just destroy it & you will see the bit of the picture that is uncovered. If the camera is set to orthographic that should help prevent any shadowing around the edges.
1 Like
yeah that’s a good solution. In game development you often don’t need/want to do things for “real”, you just want to fake things so that it looks like it.
You can also use Render Texture to make an alpha mask then apply it to the top image. More complex method but more flexible.
So on scene I have a image A (Texture Type - Sprite (2D and UI) and in my assets image B (Texture Type - Advanced, read/Write Enabled = true), image A got script
public Texture2D mainimage; ← image B
Color px_col;
px_col = mainimage.GetPixel(x, y);
For example RGBA(0.698, 0.702, 0.698, 0.706)
Actually i want to set this pixel to image A on position x1,y1. Can I do it in the same script? How?