此页面包含一些提示,可帮助您在 Unity 中获得最佳性能,涵盖动画系统和运行时优化。
注意:有关在 3D 应用程序中建模角色以在 Unity 中获得最佳性能的提示,请参阅为最佳性能建模角色。
当控制器未设置为Animator时,它不会花费时间进行处理。
播放单个动画剪辑可用于动画角色或简单动画的动画数据。它是一段简单的“单元”运动,例如(一个特定实例的)“空闲”、“行走”或“跑步”。更多信息
请参见术语表且不进行混合可能会使 Unity 比旧版动画系统慢。旧系统非常直接,对曲线进行采样并直接写入变换。Unity 当前的动画系统使用临时缓冲区进行混合,并且会额外复制采样曲线和其他数据。当前的系统布局针对动画混合和更复杂的设置进行了优化。
动画缩放曲线比动画平移和旋转曲线开销更大。为了提高性能,请避免缩放动画。
注意:这并不适用于常量曲线(在动画剪辑长度内具有相同值的曲线)。常量曲线已优化,并且比普通曲线开销更小。与默认场景场景包含游戏的环境和菜单。将每个唯一的场景文件视为一个唯一的关卡。在每个场景中,您放置环境、障碍物和装饰,从本质上讲,将游戏分成部分进行设计和构建。更多信息
请参见术语表值相同的常量曲线不会在每一帧写入场景。
大多数情况下,Unity 正在评估动画,并将动画层动画层包含一个动画状态机,用于控制模型或其一部分的动画。例如,如果您有一个用于行走或跳跃的全身体层,以及一个用于上半身动作(如投掷物体或射击)的更高层。更高的层优先控制其控制的身体部位。更多信息
请参见术语表和动画状态机动画控制器中的一个图形,用于控制动画状态的交互。每个状态都引用一个动画混合树或单个动画剪辑。更多信息
请参见术语表的开销保持在最低限度。向动画器添加另一层的成本(是否同步)取决于该层播放的动画和混合树。当层的权重为零时,Unity 会跳过层更新。
这些提示可帮助您在这两种类型之间做出选择
可以进行许多优化,一些有用的提示包括
始终通过将动画器剔除模式设置为完全剔除并禁用蒙皮网格渲染器的屏幕外时更新属性来优化动画。这可以防止 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.