一 、Drawcall 的优化
Cpu运算完了以后 需要绘制场景的时候就会调用Darwcall
想办法降低DrawCall
二 、资源的优化
移动端标准
Resources 目录下保证都是用得着的
三 、LOD
四、遮挡剔除
五、 光照贴图
六 mesh的合并
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshCombiner : MonoBehaviour {
// Use this for initialization
void Start () {
MeshCombine();
}
private void MeshCombine()
{
//获取每个子物体的mesh
MeshFilter[] filters = GetComponentsInChildren<MeshFilter>();
//专门用来处理合并的
CombineInstance[] combiners = new CombineInstance[filters.Length];
for (int i = 0; i < filters.Length; i++)
{
combiners[i].mesh = filters[i].sharedMesh;
combiners[i].transform = filters[i].transform.localToWorldMatrix; //获得filters[i]所在的Tranform 的矩阵
}
Mesh finalMesh = new Mesh(); //合并后的Mesh
finalMesh.CombineMeshes(combiners); //合并
GetComponent<MeshFilter>().sharedMesh = finalMesh;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletPool : MonoBehaviour {
public int poolCount = 30;
public GameObject bulletPrefab;
private List<GameObject> buletList = new List<GameObject>();
void InitPool()
{
for (int i = 0; i < poolCount; i++)
{
GameObject go= GameObject.Instantiate(bulletPrefab);
buletList.Add(go);
go.SetActive(false);
go.transform.parent = this.transform;
}
}
public GameObject GetBullet()
{
foreach (GameObject go in buletList)
{
if (go.activeInHierarchy==false)
{
return go;
}
}
return null;
}
}