(转)Unity 如何减少DrawCall

匿名 (未验证) 提交于 2019-12-03 00:27:02

Draw Call Batching

for(int i =0; i < 500; i++){ GameObject cube; cube = GameObject.Instantiate(prefab) as GameObject;}

for(int i =0; i < 500; i++){ GameObject cube; cube = GameObject.Instantiate(prefab) as GameObject; if(i /100 == 0) { cube.transform.localScale = new Vector3(2 + i,2 + i, 2 + i); }}

MipMap

IEnumerator DownloadAndCache (){ // Wait for the Caching system to be readywhile (!Caching.ready)yield return null;// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cacheusing(WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)){ yieldreturn www;//WWW是第1部分 if (www.error !=null)throw new Exception("WWW download had an error:" + www.error); AssetBundle bundle= www.assetBundle;//AssetBundle是第2部分if (AssetName =="")Instantiate(bundle.mainAsset);//实例化是第3部分else Instantiate(bundle.Load(AssetName));// Unload the AssetBundles compressed contents to conserve memory bundle.Unload(false); } // memory is freed from the web stream (www.Dispose() gets called implicitly) }}
WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)
AssetBundle bundle = www.assetBundle;
Instantiate(bundle.mainAsset);
using(WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)){}
//删除Web Streamwww.Dispose();
//删除AssetBundlebundle.Unload(false);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!