Version: 2022.1
言語: 日本語
バリアントスプライトアトラス
配布用スプライトアトラスの準備

スプライトアトラスワークフロー

以下の手順でスプライトアトラスを作成します。

  1. スプライトアトラス アセットを作成します。
  2. スプライトアトラスの Objects for Packing のリストを選択します。
  3. スプライトアトラスの Include in build を有効にしてプロジェクトに追加します。
  4. (任意) バリアントスプライトアトラス を作成します。
  5. (任意) スプライトアトラスを 配布 用に準備します。
    • 配布用に準備されたスプライトは、スクリプトを使った 遅延バインディング (Late Binding) で読み込む必要があります。
  6. (任意) パフォーマンスを向上させるために、プロジェクトのスプライトアトラスの使用とサイズを 最適化 します。

スプライトアトラスアセットの作成

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.

Objects for Packing リストのアイテムを選択する

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).

リストの特定のアイテムを選択するには、以下の手順を行います。

  1. スプライトアトラスアセットを選択し、Inspector ウィンドウで Objects For Packing リストを確認します。そこには、Unity がスプライトアトラスをビルドするときにパックするアイテムのリストが表示されます。

  2. 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.

  3. Select Pack Preview to preview the combined Atlas Texture in the Asset Preview window.

Include in Build

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’ を無効にすると、この動作は 行なわれなくなり、スプライトアトラスの 配布 の準備の際に行われます。

Optimizing Sprite Atlas usage and size for improved performance

シーンでスプライトがアクティブになると、Unity はスプライトに属するスプライトアトラスとスプライトアトラスに含まれるすべてのテクスチャを読み込みます。非常に大きなテクスチャを含むスプライトアトラスを読み込み、シーンでこれらのほとんどのテクスチャを使用しない場合、パフォーマンスのオーバーヘッドが大きくなる可能性があります。

スプライトアトラスの使用を最適化するために、理想的には、シーンでアクティブなすべてのスプライト、またはほとんどのスプライトを、同じアトラスに含む必要があります。共に使用するものをまとめて、複数の小さなアトラスに分割することが効果的です。

パフォーマンスのオーバーヘッドを削減するもう 1 つの方法は、スプライトアトラスのパックしたテクスチャ間の空のスペースを減らすことです。これにより、スプライトアトラスのサイズが小さくなります。これを行うには、スプライトアトラスを選択し、Inspector ウィンドウの下方にあるパックプレビューウィンドウでパックしたアトラステクスチャを確認します。プレビューがない場合は、Objects for Packing リストの下にある Pack Preview ボタンを押して、パックしたテクスチャを生成します。

Sprite Atlas with excess empty space.
Sprite Atlas with excess empty space.

空のスペースが余分に表示されている場合は、パックしたテクスチャのサイズを手動で減らして空のスペースを減らし、アトラスのサイズを最適化することができます。これを行うには、Inspector ウィンドウ下部の プラットフォームごとのオーバーライド パネルに移動します。Max Texture Size のドロップダウンメニューから低い値を選択し、Pack Preview を押して、パックしたテクスチャを生成します。

Set the Max Texture Size.
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.
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.

バリアントスプライトアトラス
配布用スプライトアトラスの準備
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961