GameObject/Sprite Masking - How to?

So I’m using Unity for a 2D game and I know there is the UI Masking feature, but how do i mask a GameObject?

I simply need to mask the outer parts of the boxes to give them the effect of being inside the dark portion of the circle.

So turn this:

alt text

into this:

alt text

Please help! I’ve been stuck on this for a while. Can’t seem to get it.

There are two ways that I could think of doing this, and one is considerably easier than the other.

You could create a second camera that doesn’t render the UI elements, and only sees the game objects. Make this camera render its view to a RenderTexture. Then, in your Canvas, create a “Raw Image”, and assign it to show the RenderTexture. Since this image is a UI element, it should work normally with UI masks.

The second way requires you to create a custom shader, and that’s a lot of work and no fun at all :stuck_out_tongue: