- Home /
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:
into this:
Please help! I've been stuck on this for a while. Can't seem to get it.
Answer by alexi123454 · Jul 20, 2015 at 08:12 PM
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 :P
Your answer
Follow this Question
Related Questions
Deform sprite using SkinnedMeshRenderer 0 Answers
How to mask a 2d Game Board using Unity 4.3 2D GameObjects 0 Answers
Broken UI Mask and downsides of using OpenGLES2 0 Answers
Masking an image 0 Answers
Masking a MeshRenderer 0 Answers