Modeling characters for optimal performance:模型的处理优化
Use a single skinned Mesh Renderer
使用单个 skinned Mesh Renderer,使用的越多性能消耗越大
Use as few materials as possible
使用尽量少的材质球,因为材质球越多,shader越多
Use as few bones as possible
使用尽量少的层级
Polygon count
控制多边形数量,移动平台上,每一个网格在300-1500之内比较好,PC平台上每个网格的多边形数量在 1500 to 4000.
Keep forward and inverse kinematics separate
反向运动学和正向运动学分开
Rendering Statistics Window
点击status面板,打开渲染统计窗口
Time per frame and FPS | 处理和渲染一个游戏帧所花费的时间(以及相应的每秒帧数)。注意,这个数字只包括做帧更新和渲染游戏视图所花费的时间;它不包括在编辑器中绘制场景视图所花费的时间。 |
Batches | “批处理”是指引擎试图将多个对象的呈现合并到一块内存中,以减少由于资源切换造成的CPU开销。 |
Saved by batching | 合并的批次数. |
Tris and Verts | 绘制的三角形和顶点的数量 |
Screen | 屏幕的大小,以及它的抗锯齿水平和内存使用情况。 |
SetPass | 渲染passes的次数。每一个pass都需要Unity运行时绑定一个新的着色器,这可能会带来CPU开销。 |
Visible Skinned Meshes | 所呈现的蒙皮网格的数量。 |
Animations | 播放的动画数量。 |
Texture Streaming
Texture Streaming system能够让你控制unity内存中加载的texture,这个系统减少了Unity需要纹理的内存总量,因为它只加载了Unity需要渲染场景中当前摄像机位置的mipmaps,它通过交换少量的CPU资源来节省大量的GPU内存。
你可以使用Texture System API 去加载具体的texture.
Texture Streaming setup
在 (Edit > Project Settings> Quality) 打开 Texture Streaming 多选框.
打开texture的属性面板,点击Advance--> Streaming Mip Maps 复选框
如果你是为Android开发的, 你需要打开 Build Settings 设置 Compression Method to LZ4 or LZ4HC.Unity需要一种 asynchronous Texture loading异步纹理加载的压缩方法,这也是Texture Streaming system纹理流系统所依赖的