Sprite Editor の Custom Physics Shape を使用すると、スプライトの物理形状を編集できます。スプライトの物理形状はスプライトの Collider 2D メッシュの初期形状を決定します。コライダーのコンポーネント設定で物理形状をさらに細かく調整できます。
スプライトの物理形状の編集は以下の手順で行います。
Project ウィンドウで、編集したいスプライトを選択します。
Inspector ウィンドウで Sprite Editor ボタンをクリックします。
Sprite Editor ウィンドウで、左上のドロップダウンから Custom Physics Shape を選択します。
プロパティ | 機能 |
---|---|
Snap | コントロールポイントを最も近いピクセルにスナップします。 |
Outline Tolerance | 作成された輪郭がスプライトテクスチャの輪郭にどれだけ厳密に従うかを制御します。最小値 (0) で、スプライトエディターはスプライトの周囲に基本的な輪郭を作成します。最大値 (1) では、スプライトエディターはスプライトのピクセルによる輪郭にできるだけ近い輪郭を作成します。 |
Generate | クリックすると、自動的に物理形状の輪郭を作成します。 |
最初に、選択したスプライトの Sprite Editor を開きます。次に、エディターの左上のドロップダウンメニューから Custom Physics Shape を選択します。
次に Generate をクリックして、物理形状の輪郭を作成します。Unity はデフォルトで、元となる スプライト テクスチャの形状に沿った輪郭を生成します。透明領域も考慮されます。
Outline Tolerance スライダーを調整して、物理形状の輪郭を精細にします。 Outline Tolerance 値を調整した後、Generate をクリックして輪郭を更新します。
各制御点をクリックアンドドラッグして、物理形状の輪郭を調整します。制御点を削除するには、制御点を選択して Command + Del/Del キーを押します。
輪郭の上にマウスオーバーすると、端に沿って透明な制御点が表示されます。それをクリックすると、新しい制御点が作成されます。制御点を削除するには、それを選択して Del/Command+Del キーを押します。
![]() |
![]() |
Fig.1: Transparent control point. | Fig.2: Click to create new control point. |
複数の制御点を選択するには、任意の領域をクリックしてからドラッグします。選択している間に、設定や削除ができます。
制御点でなく、エッジを選択するには、Control/Ctrl キーを押したままにします。 エッジを新しい位置に動かすには、ハイライトされたエッジをクリックしドラッグします。
![]() |
![]() |
Fig.1: Select the edge of the outline. | Fig.2: Drag and move the edge freely once selected. |
1 つの物理形状に複数の別々の輪郭を含めることができます。これは、スプライトの特定の領域だけが衝突のための Collider 2D メッシュを必要とする場合に便利です。例えば、あるキャラクターのスプライトにゲームメカニックスの一部としてダメージを与えるために、特定の領域の衝突にのみ反応させたい場合があるかもしれません。
Sprite Editor ウィンドウの任意の空いているスペースをクリックしてドラッグします。これにより、4 つの制御点を持つ新しい矩形が作成されます。追加の矩形を作成するには、この手順を繰り返します。物理形状の輪郭と同じ方法で、それぞれを調整できます。
![]() |
![]() |
Fig. 1: Click and drag to create 4-point box. | Fig. 2: Box physics shape with 4 control points. |
![]() |
![]() |
Fig. 3: Click and drag again for another box. | Fig. 4: Repeat to create more separate outlines. |
既存のゲームオブジェクトがすでに参照として使用されているスプライトの輪郭を編集する場合は、Collider 2D コンポーネントのラベルを右クリックして Reset を選択します。これにより、Collider 2D メッシュの形状が更新されます。
2018–05–24 公開ページ
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.