Resolving different Sprite Atlas scenarios
The way Unity resolves the interaction between SpritesA 2D graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. More info
See in Glossary and Sprite Atlases depends on various conditions. The examples below detail the most common scenarios:
Scenario 1: Basic Sprite Atlas usage
-
Sprite Atlas A contains Sprite 1.
-
Sprite Atlas A has Include in Build enabled.
- 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
-
Sprite Atlas A contains Sprite 1.
-
Sprite Atlas A has Include in Build disabled.
- 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
-
Sprite Atlas A and Sprite Atlas B both include Sprite 1 in their Objects for Packing lists.
- Both Sprite Atlas A and Sprite Atlas B have Include in Build enabled.
- Both Sprite Atlases have different Texture output settings in this example.
- 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 AtlasA texture that is composed of several smaller textures. Also referred to as a texture atlas, image sprite, sprite sheet or packed texture. More info
See in Glossary you want, follow the steps below:
- Disable ‘Include in Build’ for both Sprite Atlases.
- 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.