---
description: This section describes how to mask sprites.
---

# Sprite Masking

## What is Masking?

<figure><img src="https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2FPOcNmXsZWg2aWDLgnHOZ%2Fmask.gif?alt=media&#x26;token=2b0443c2-aa05-4197-b906-dea98b811420" alt=""><figcaption></figcaption></figure>

* In Unity, the mask is a component that automatically crops the target sprite like a window.
* Technically, you will need two game objects: **the target object** and the **masking object**.
* You can add one of the game objects as a child if you want.\
  ![](https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2FevmDmSmrt3sFrpbBFfwy%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202022-11-24%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%201.12.53.png?alt=media\&token=e9ceae7f-e01f-4371-9fc3-34318a015506)
* If you want to use the masking for your Avatar, you should use the **Rigged Mask 2D Component** instead of the Sprite Mask.&#x20;

{% hint style="danger" %}
The Sprite Mask **wouldn’t work on rigged sprites** in Unity.&#x20;
{% endhint %}

## How to apply the masking effect?

1\. It is pretty straightforward. Make sure to select the GameObject that you want to use as a Mask

2\. In the inspector, click the <mark style="color:purple;">`add component`</mark> button and select the <mark style="color:purple;">`Rigged Mask 2D`</mark>.

<figure><img src="https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2F0gIt36OZQ59fFSVhvcID%2F1.png?alt=media&#x26;token=9296e7c5-1db9-4cd5-8c0d-f9c63d9a2e27" alt=""><figcaption></figcaption></figure>

3\. Tab the <mark style="color:purple;">`Fit to source sprite`</mark> button.

<figure><img src="https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2FBagclDqe03H9P1VBKNBJ%2F2.png?alt=media&#x26;token=3ca2ac5b-fd02-4363-ba44-4f97941a32f7" alt=""><figcaption></figcaption></figure>

4\. That’s it. Now you will see the source sprite is cropped.

<figure><img src="https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2FbjZNdrxGN6lkAyree62t%2F3.png?alt=media&#x26;token=ffa5c37d-eab5-42df-8106-0226eaebd1ed" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
It is not going to be working **if the masking sprite has multiple bones**
{% endhint %}

{% hint style="success" %}
**If you want to animate masking sprites**, you might need to add the Sprite Resolver
{% endhint %}

5\. There are several options that you could choose from in the Mask Interaction.

* None
* Visible inside Mask
* Visible outside Mask

<figure><img src="https://1381431913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CBs7vCLqptAiFUTrCYl%2Fuploads%2FHEDHGj8ZdinypNYB8yI2%2F4.png?alt=media&#x26;token=8811112d-ea19-4479-aa79-3d3a3e64428b" alt=""><figcaption></figcaption></figure>
