当一个精灵二维图形对象。如果您习惯于使用 3D,则精灵本质上只是标准纹理,但有一些特殊的技术可以组合和管理精灵纹理,以便在开发过程中提高效率和便利性。更多信息
参见 术语表在场景场景包含游戏环境和菜单。可以将每个唯一的场景文件视为一个唯一的关卡。在每个场景中,您放置环境、障碍物和装饰,本质上是分段设计和构建您的游戏。更多信息
参见 术语表中处于活动状态时,Unity 会加载它所属的精灵图集一种实用程序,可将多个精灵纹理紧密地打包到一个称为图集的单个纹理中。更多信息
参见 术语表以及它包含的所有纹理。如果 Unity 加载一个包含非常大纹理的精灵图集,而场景中没有任何内容正在使用这些纹理的大部分,则这可能会导致过多的性能开销。
为了优化精灵图集的使用,理想情况下,场景中处于活动状态的所有或大部分精灵都应属于同一个图集。最佳实践是根据精灵纹理的常用情况将其拆分为多个较小的图集。
另一种减少性能开销的方法是减少精灵图集打包纹理之间的空白区域。这会减小精灵图集的大小。为此,选择精灵图集,并在其检查器一个 Unity 窗口,显示有关当前选定游戏对象、资源或项目设置的信息,允许您检查和编辑值。更多信息
参见 术语表设置底部的“打包预览”窗口中检查打包的图集纹理。如果没有可用的预览,请在“打包对象”列表下选择“打包预览”按钮以生成打包的纹理。
带有过多空白区域的精灵图集。
如果存在可见的过多空白区域,您可以手动减小打包纹理的大小,以减少空白区域的数量并优化图集的大小。为此,请转到检查器窗口底部的“平台特定覆盖”面板。从“最大纹理大小”设置的下拉菜单中选择较低的值,然后选择“打包预览”以重新生成打包的纹理。
设置最大纹理大小。
当“最大纹理大小”值小于精灵图集纹理的当前尺寸时,Unity 会尽可能减小打包纹理的尺寸以匹配设定的“最大纹理大小”,并自动修剪掉任何额外的空白区域。如果选定的精灵纹理超过了精灵图集的“最大纹理大小”设置,则精灵图集会忽略“最大纹理大小”设置,并保持包含精灵纹理在其原始尺寸所需的最小大小。
精灵图集中的纹理保持其原始尺寸。
注意:当使用变体精灵图集时,选择非常小的缩放值(小于 0.25)可能会导致视觉伪像,具体取决于使用的压缩一种存储数据的方法,可减少其所需的存储空间。参见 纹理压缩、动画压缩、音频压缩、构建压缩。
参见 术语表格式和精灵的原始分辨率。建议在使用变体图集时使用较高的填充值和更好的压缩格式。
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.