# Mesh in Unity

## What is Mesh?

* Mesh is a **polygon that the Unity makes the image deformation.**&#x20;
* When you open the PSB through the <mark style="color:purple;">`sprite editor`</mark>, the **Unity2D system will create the polygons automatically**.

<figure><img src="/files/hwVH0jd63JTwjtjKph3t" alt=""><figcaption><p>Mesh will be created automatically by clinking 'Opne Sprite editior'</p></figcaption></figure>

### When do we need Mesh?

* Like a human body, we need to add bones to the image.

<figure><img src="/files/wT245XFSTmONuVJ4sD6f" alt=""><figcaption></figcaption></figure>

* With skeletal animation, you can make all the animations from a single sprite.
* When the polygon is defined inside the image, then its vertices can be manipulated to deform the image with the Unity Bone system.

## How to apply Mesh

1\. To create a mesh, you might need to select a <mark style="color:purple;">`PSB`</mark> in your project, when you see the inspector tab. Clicking the <mark style="color:purple;">`sprite editor`</mark> button will show the sprite editor popup window.

<figure><img src="/files/hYcomRchYY4H4SYBgbaa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/3kg8V8ZObjt32Da5MbkH" alt=""><figcaption></figcaption></figure>

2\. Once you get the popup window, you will need to change the <mark style="color:purple;">`Sprite Editor`</mark> to the <mark style="color:purple;">`Skinning editor`</mark>.

<figure><img src="/files/3JBm2zg6595JuRtM2Lcz" alt=""><figcaption></figcaption></figure>

3\. You will see the auto-generated mesh when you tap the <mark style="color:purple;">`Auto Geometry`</mark> button. You can also Re-Generate the mesh if you don’t like it. In the options menu, you could choose the **detail of the outline**, **alpha tolerance** and **subdivide**. The options could be different for each image.

<figure><img src="/files/GqQLqcnRZC7sJUHGd9Ek" alt=""><figcaption></figcaption></figure>

4\. Because of the performance, **we recommend you manually adjust all the mashes as much as possible.**

For example, you might need to **clean up the useless vertexes**. This will helps you set the bone much easier. You can add or delete the vertexes through the <mark style="color:purple;">`Create Vertex`</mark> button.

<figure><img src="/files/4vF2xBKYoTk7SD2cDL5L" alt=""><figcaption><p>Process of adjusting vertexes</p></figcaption></figure>

<figure><img src="/files/uc1rUCZOkVh32FvGNrjt" alt=""><figcaption><p>(Left) Automatic generated mesh , (Right) Manually adjusted mesh</p></figcaption></figure>

5\. How to add bone?&#x20;

<figure><img src="/files/6UK4uJAxdPwklXRVpTyc" alt=""><figcaption></figcaption></figure>

Once you have finished your mesh, the next stage is **adding bones**. Click and drag to create the first bone, following your design.

Furthermore, if you want to adjust the Weights, click the <mark style="color:purple;">`Auto weights`</mark> button.

<figure><img src="/files/azuGEwuRCyCSCqpS6ZpG" alt=""><figcaption><p>Automatically applied weights</p></figcaption></figure>

<figure><img src="/files/t8MNbGvbUgO1dAwhR3ii" alt=""><figcaption><p>A sprite that moves along a bone with a weight applied</p></figcaption></figure>

6\. **Always, you will need to adjust weights for the vertex.** It’s up to you but remember, no pain no gain 🙂. There are two more useful tools that you can use for adjusting.&#x20;

* The <mark style="color:purple;">`Weight Slider`</mark> will help you if you want to set the value accuracy.
* <mark style="color:purple;">`Weight Brush`</mark> would be great if you don’t want to spend much time doing the rigging.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://myty.gitbook.io/products/kit/make-animation/7.-rigging-in-sprite-editor/mesh-in-unity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
