Slice ツールを選択し、その Type を Automatic に設定すると、Unity は、個々の潜在的なスプライトの周囲の透明度に基づいて境界を生成して、自動的にテクスチャを複数の離れたスプライトにスライスします。自動スライス は、例えば、タイルシート内の個々の タイル のように、テクスチャ内で一定間隔でグラフィカルな画像を分離します。
Sprite Editor のツールバーから Slice ツールを選択し、Type を Automatic に設定すると、以下のようなエディターパネルが表示されます。
このパネルでは、Pivot および Custom Pivot オプションを使用して、スライスされたスプライトごとにデフォルトのピボットを設定できます。自動スライスの適用前にエディターウィンドウ内に既存の選択範囲がある場合は、Method (方法) メニューの以下のオプションから、Unity が既存の選択範囲をどのように処理するかを選択してください。
方法 | 機能 |
---|---|
Delete Existing | テクスチャ内の全ての SpriteRect を削除し、新しくスライスされた SpriteRect を追加します。 |
Smart | 新しくスライスされた SpriteRect が 1 つまたは複数の既存の SpriteRect と重なる場合、最もよく重なっている元の SpriteRect の位置とサイズが、新しくスライスされた SpriteRect の位置とサイズに更新されます。この新しくスライスされた SpriteRect は、その後破棄されます。 |
Safe | 元の SpriteRect を全て維持します。新しくスライスされた SpriteRect が既存の SpriteRect と重なる場合、それは破棄されます。 |
スライスの Type には、Grid by Cell Size および Grid by Cell Count オプションも提供されています。これは、スプライトが作成中にすでに一定のパターンで配置されている場合に便利です。
Pixel Size の値は、タイルの高さと幅をピクセル単位で指定します。Grid by Cell Count を選択した場合は、Column & Row でスライスに使用する列と行の数を指定できます。また、Offset の値でグリッドの位置を画像の左上からずらしたり、Padding の値で SpriteRect をグリッドから少しずらしたりできます。Keep Empty Rects オプションを有効にすると、ピクセルのない SpriteRect を保持できます。これは、テクスチャから作成されたスプライトをテクスチャ内での位置に基づいて整理するのに便利です。Pivot には、9 つのプリセット位置のうち 1 つを設定するか、Custom Pivot 位置 (カスタムのピボット位置) を設定することができます。
Isometric Grid オプションは、高さが半分のひし形の列が交互に配置されたスプライトを持つスプライトシートのスライスを試みます。スライスされた SpriteRect は、高さが半分のひし形に対応するカスタムアウトラインと物理形状を持ちます。
Is Alternate オプションは、アイソメトリックなひし形を列ごとに互い違いに並べるかどうか指定します。有効にすると、一番上の列の最初のひし形が、左端から半ピクセル分ずれた位置から開始することが想定されます。無効にすると、最初のひし形が、左端の位置から直接開始します。
Grid オプションを使用してスライスする場合は、スライスのガイドとして、SpriteRect のプレビューがテクスチャ上に表示されます。スライスの設定を調整すると、それに応じてプレビューが更新されます。既存の SpriteRect の処理に使用された方法や、プレビュー SpriteRect のピクセルの内容によっては、スライスを行っても、プレビューに表示された SpriteRect が生成されない場合があります。
なお、どの 自動スライス 方法で生成された SpriteRect も、手動編集によって形状の微調整が可能です。
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.