2D Toolkit Forum

2D Toolkit => Support => Topic started by: polphit on October 03, 2013, 11:00:22 am

Title: Composing a (alpha-textured) sprite onto another sprite to make a hole
Post by: polphit on October 03, 2013, 11:00:22 am
Hello,

I would like to make a wall on which (at random position) a window is. I want to see scenes through the window.
So I want to
    1) make a wall sprite W
    2) render a window (a hole and its frame) sprite H onto W
    3) here, a region (in H) of alpha = 0 should be a hole in W after the composition

Can anyone help me to do it?
thank you in advance.
Title: Re: Composing a (alpha-textured) sprite onto another sprite to make a hole
Post by: unikronsoftware on October 03, 2013, 05:49:22 pm
You can use render textures if you have Unity Pro. Or if you don't, you could use texture.readpixels & setpixels to read and modify the texture. This is a slow operation though, so you don't want to do this every frame.