Unity 解析精灵和精灵图集之间交互情况的方式取决于各种条件。以下示例详细展现了最常见的情形:
1.精灵图集 A 包含__精灵 1。 2.精灵图集 A__ 启用 Include in Build。 3.结果:项目发布的构建中包含__精灵图集 A。精灵 1__ 使用__精灵图集 A__ 中的纹理进行渲染。
1.精灵图集 A 包含__精灵 1。 2.精灵图集 A__ 禁用 Include in Build。 3.结果:项目发布的构建中不包含__精灵图集 A__,也不包含__精灵 1__ 的纹理。精灵 1 在运行时在构建中不可见,因为其引用的纹理不可用且未加载。
1.精灵图集 A 和__精灵图集 B__ 两者均在自己的 Objects for Packing 列表中包含__精灵 1。 2.精灵图集 A__ 和__精灵图集 B__ 两者均启用 Include in Build。 3.在此示例中,两个__纹理图集__具有不同的纹理输出设置。 4.结果:项目发布的构建中包含两个精灵图集。Unity 会在一个不受控制的内部过程中随机选择使用哪个纹理来渲染__精灵 1__。
在此情形中,要确保精灵使用所需精灵图集中的纹理进行渲染,请按照以下步骤操作:
1.为两个精灵图集都禁用 Include in Build。 2.在运行时初始化精灵时,直接使用 SpriteAtlas.GetSprite 从其中一个图集请求精灵。这样可确保 Unity 始终从正确的精灵图集绘制精灵纹理。
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.