How to creat a mask on a layer in 2D ?

In photoshop and after effects, when I want to hide something on a layer, a simply create a mask around it, and it disapear, I see the layer below instead.

Sooo can I do that in Unity ? because for my 2D game I really need that.


If you want a transparent mask you’ll have to use shaders but I’m pretty sure you can achieve the effect you want using Sprite Renderer and sorting order.

Sprites have sorting layers and sorting orders.
Go to edit->project settings->Tags and Layers.
Now expand the Sorting Layers. Here you can manage your 2d layers.

On the sprite renderer component you can change which layer and order it uses. Order is for the z-order of sprites on the given layer.

With this you can hide one sprite behind another and create masks.

You can also loop through all objects in that layer at Start() and do this

GetComponent<MeshRenderer>().enabled = false; //Make invisible

Might not be the optimal solution, but it’s a solution :slight_smile: