以下の手順でスプライトアトラスを作成します。
To create the Sprite Atlas Asset, go to Assets > Create > 2D > Sprite Atlas. Unity creates the Sprite Atlas in the Asset folder, with the file extension * .spriteatlas.
The Objects for Packing list displays the currently selected items that are in the Sprite Atlas. You can place Texture2D and Sprite Assets in this list. Drag and drop a folder directly onto the list to automatically add all valid content within the folder to the list (only the folder appears on the list).
リストの特定のアイテムを選択するには、以下の手順を行います。
スプライトアトラスアセットを選択し、Inspector ウィンドウで Objects For Packing リストを確認します。そこには、Unity がスプライトアトラスをビルドするときにパックするアイテムのリストが表示されます。
To add items, select the plus (+) icon at the lower right of the list to create a new row. Drag a valid Asset onto an empty row to add it to the list, or select the circle icon to the right of the row to open the Select Object window. Select an Asset from the Object Picker window to add it to the list:
To remove an item from the list, click the minus (-) icon at the lower right of the Objects For Packing list. To replace an item, drag another item to the row it occupies to replace it on the list.
Select Pack Preview to preview the combined Atlas Texture in the Asset Preview window.
All Sprite Atlases have Include in Build enabled by default when created. This means that Unity includes the Sprite Atlases with the Project’s build and automatically loads them at the build’s run time. Enable or disable the ‘Include in Build’ property to control which Sprite Atlases are included in the Project build.
‘Include in Build’ を無効にすると、この動作は 行なわれなくなり、スプライトアトラスの 配布 の準備の際に行われます。
シーンでスプライトがアクティブになると、Unity はスプライトに属するスプライトアトラスとスプライトアトラスに含まれるすべてのテクスチャを読み込みます。非常に大きなテクスチャを含むスプライトアトラスを読み込み、シーンでこれらのほとんどのテクスチャを使用しない場合、パフォーマンスのオーバーヘッドが大きくなる可能性があります。
スプライトアトラスの使用を最適化するために、理想的には、シーンでアクティブなすべてのスプライト、またはほとんどのスプライトを、同じアトラスに含む必要があります。共に使用するものをまとめて、複数の小さなアトラスに分割することが効果的です。
パフォーマンスのオーバーヘッドを削減するもう 1 つの方法は、スプライトアトラスのパックしたテクスチャ間の空のスペースを減らすことです。これにより、スプライトアトラスのサイズが小さくなります。これを行うには、スプライトアトラスを選択し、Inspector ウィンドウの下方にあるパックプレビューウィンドウでパックしたアトラステクスチャを確認します。プレビューがない場合は、Objects for Packing リストの下にある Pack Preview ボタンを押して、パックしたテクスチャを生成します。
Sprite Atlas with excess empty space.
空のスペースが余分に表示されている場合は、パックしたテクスチャのサイズを手動で減らして空のスペースを減らし、アトラスのサイズを最適化することができます。これを行うには、Inspector ウィンドウ下部の プラットフォームごとのオーバーライド パネルに移動します。Max Texture Size のドロップダウンメニューから低い値を選択し、Pack Preview を押して、パックしたテクスチャを生成します。
Set the Max Texture Size.
スプライトアトラステクスチャの現在のサイズが Max Texture Size の値よりも大きい場合、Unity はパックしたテクスチャのサイズを Max Texture Size にできるだけ近くなるように縮小し、余分な空の部分を自動的にトリムします。スプライトアトラスの Max Texture Size 設定を超えるスプライトテクスチャを選択すると、スプライトアトラスは Max Texture Size 設定を無視し、スプライトテクスチャを元のサイズで含むために必要な最小サイズを維持します。
Textures in a Sprite Atlas remain in their original dimensions.
Note: When using Variant Sprite Atlases, selecting a very low scale value (less than 0.25) may result in visual artifacts, depending on the compression format used and original resolution of the Sprite. It is recommended to use high padding values and better compression formats when using Variant Atlases.
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.