Painting on a texture's alpha channel

Hi,

I am trying to do like a scratching effect on a texture so that when the user drags his finger on the screen, the texture below the first one should appear (but only in places where the upper texture is “scratched”). I suppose I should somehow paint the upper textures alpha channel so that it is invisible in the places where use drags (using another texture as a brush)… this code below works but of course it’s not good because this happens every frame if the user is dragging so soon Unity will run out of memory (every frame the new texture is instantiated). Well actually my question is… how to do this right so that it works on mobile devices. Thanks for any help!

i edited the code… sorry I pasted the wrong one. In this code I am using the new instantiated image…

Texture2D DrawOnImage(Texture2D baseImage, Texture2D brushImage, int cx, int cy)
{
    Texture2D newImage = (Texture2D)Instantiate(baseImage);
       for (int y = 0; y < brushImage.height; ++y)
       {
           for (int x = 0; x < brushImage.width; ++x)
           {
               Color compositeColor = brushImage.GetPixel(x, y);
               Color baseColor = baseImage.GetPixel(cx + x, cy + y);
               Color newColor = new Color(1, 1, 1, compositeColor.a);
               newImage.SetPixel (cx+x, cy+y, newColor);
            }
        }
        return newImage;
}

You don’t need to instantiate a new texture each time, you aren’t even using it.

Dave I corrected my code