Result: The Project’s published build includes Sprite Atlas A. Sprite 1 renders with the Texture from Sprite Atlas A.
情形 2:禁用“Include in Build”
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.
情形 3:一个精灵位于两个精灵图集中
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.
在此情形中,要确保精灵使用所需精灵图集中的纹理进行渲染,请按照以下步骤操作:
Disable ‘Include in Build’ for both Sprite Atlases.
2.在运行时初始化精灵时,直接使用 SpriteAtlas.GetSprite 从其中一个图集请求精灵。这样可确保 Unity 始终从正确的精灵图集绘制精灵纹理。