- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
 
- 纳金币
- 53488
- 精华
- 316
|
1.静态批量处理。unity自带。 注意物体无法随着父物体整体移动。
2.如果需要整体移动,但是又想静态处理。可以使用StaticBatchingUtility.Combine (this.gameObject); 创建一个空物体,将整体移动场景作为其子物体,将脚本挂载到空物体上。注意在Awake中,经过实际测试,DC降了一半。
3.遮挡剔除。遮挡物不多不建议使用。
4.优化粒子效果。降低模型定点数面片数目。多用相同材质。
5.删除不必要的mesh collider和animation。批量删除代码如下。注意编辑器模式
[ContextMenu("编辑器模式下运行")] //选择这个模式运行,不需要启动游戏。 其中还有批量添加删除组件。
void Start () {
Transform[] allChildren = GetComponentsInChildren<Transform>(); //GameObject.GetComponentsInChildren
foreach (Transform child in allChildren) {
if(child.name != "city"){
child.gameObject.AddComponent<BoxCollider>();
Animator an = child.gameObject.GetComponent<Animator>();
DestroyImmediate(an);
Animation an1 = child.gameObject.GetComponent<Animation>();
DestroyImmediate(an1);
MeshCollider mesh = child.GetComponent<MeshCollider>();
DestroyImmediate(mesh);
AssetDatabase.SaveAssets();
//EditorApplication.SaveScene();
}
}
}
6.图集。然后用精灵分割。具体没看见效果。可能由于我的项目UI太少。
7.代码优化,少用临时变量,少用foreach,少用getcomponent。可使用transfrom。标签,拖拽。
后续会继续补充。欢迎大家指出错误和不足。
|
|