欢迎光临散文网 会员登陆 & 注册

代码优化(2)

2020-05-26 10:46 作者:unity_某某师_高锦锦  | 我要投稿

合并成静态网格

using UnityEngine;

using System.Collections;

using System.Collections.Generic;


[System.Serializable]

public struct GameObjectList {

public string name;

public List<GameObject> _objects;

}


public class StaticBatchTester : MonoBehaviour {


[SerializeField] List<GameObjectList> _objectList;


void Update() {

if (Input.GetKeyDown (KeyCode.Space)) {

BatchObjects();

}

}


void BatchObjects() {

for(int i = 0; i < _objectList.Count; ++i) {

GameObjectList list = _objectList[i];

for(int j = 0; j < list._objects.Count; j++) {

StaticBatchingUtility.Combine (list._objects.ToArray(), gameObject);

}

}

}

}


代码优化(2)的评论 (共 条)

分享到微博请遵守国家法律