How do I blend a transparent texture with an opaque one?

I have two RGBA32 textures from PNG files, one is opaque, the other one has opaque pixels, completely transparent pixels, and shadow pixels (black with 50% alpha. In the inspector, I can see the alpha of my transparent texture properly, I see black, white and grey.

Let’s assume for argument’s sake that both textures have the same resolution, say 32px * 64px. I am using:

color2 = texture2.getpixels(0,0,32,64);

but when I render texture1 it shows texture2 only with white where the transparency (so the layer below) is supposed to be. I actually want to layer the two textures one on top of the other and use the result as one texture (including darkened parts by the “shadow” pixels.

If I set “Alpha is transparency” in the import settings, it appears even worse. The texture clamps on the pixels that should be completely transparent and the half-transparent ones appear black.

What am I doing wrong?

Have you checked the value of color2.a?

Is texture1 the right format (ARGB32) and Read/Write enabled?

thanks, this helped me a lot!