Version: 2021.1
Late Binding
Sprite Packer Modes

Resolving different Sprite Atlas scenarios

The way Unity resolves the interaction between Sprites and Sprite Atlases depends on various conditions. The examples below detail the most common scenarios:

Scenario 1: Basic Sprite Atlas usage

  1. Sprite Atlas A contains Sprite 1.
  2. Sprite Atlas A has Include in Build enabled.
  3. Result: The Project’s published build includes Sprite Atlas A. Sprite 1 renders with the Texture from Sprite Atlas A.

Scenario 2: ‘Include in Build’ is disabled

  1. Sprite Atlas A contains Sprite 1.
  2. Sprite Atlas A has Include in Build disabled.
  3. Result: The Project’s published build does not include Sprite Atlas A, and does not include Sprite 1’s Texture. Sprite 1 appears invisible in the build at run time, because the Texture it refers to is not available and is not loaded.

Scenario 3: One Sprite in two Sprite Atlases

  1. Sprite Atlas A and Sprite Atlas B both include Sprite 1 in their Objects for Packing lists.
  2. Both Sprite Atlas A and Sprite Atlas B have Include in Build enabled.
  3. Both Sprite Atlases have different Texture output settings in this example.
  4. Result: The Project’s published build includes both Sprite Atlases. Unity randomly chooses which Texture to render Sprite 1 with, in an internal process that is out of your control.

In this scenario, to ensure that the Sprite renders with the Texture from the Sprite Atlas you want, follow the steps below:

  1. Disable ‘Include in Build’ for both Sprite Atlases.
  2. When you initialize the Sprite at run time, request the Sprite directly from one of the Atlases with SpriteAtlas.GetSprite. This ensures that Unity always draws the Sprite Texture from the correct Sprite Atlas.
Late Binding
Sprite Packer Modes
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961