本页面提供一些提示来帮助您在 Unity 中获得最佳性能,内容涵盖动画系统和运行时优化。
注意:有关在 3d 应用程序中为角色建模以便在 Unity 中获得最佳性能的技巧,请参阅角色建模的性能优化。
播放没有混合的单个动画剪辑会使 Unity 的速度比旧版动画系统更慢。旧系统非常直接,对曲线采样并直接写入变换中。Unity 的当前动画系统具有用于混合的临时缓冲区,并会对采样曲线和其他数据进行额外复制。当前系统布局已针对动画混合和更复杂设置进行优化。
动画化缩放曲线比动画化移动和旋转曲线的成本更高。为了改善性能,请避免使用缩放动画。
注意:这不适用于常量曲线(具有相同动画剪辑长度值的曲线)。常量曲线经过优化,成本低于比普通曲线。常量曲线的值与默认场景值相同时,常量曲线不会每帧都写入场景。
大多数时间,Unity 都在估算动画,并将动画层和动画状态机的开销保持在最低水平。向 Animator 添加另一层(无论同步与否)的成本取决于层播放的动画和混合树。层的权重为零时,Unity 会跳过层更新。
以下提示可帮助您选择具体类型:
可进行许多优化,一些有用的提示如下:
始终通过将 Animator 的 Culling Mode 设置为 Based on Renderers 来优化动画,并禁用蒙皮网格渲染器的 Update When Offscreen 属性。这样即可在角色不可见时让 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.