GetComponent<Renderer>().material.color = Color.red;
public void CombineMeshes (
CombineInstance[] combine,
bool mergeSubMeshes= true,
bool useMatrices= true
);
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class ExampleClass : MonoBehaviour {
void Start() {
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i = 0;
while (i < meshFilters.Length) {
combine[i].mesh = meshFilters[i].sharedMesh;
combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
meshFilters[i].gameObject.active = false;
i++;
}
transform.GetComponent<MeshFilter>().mesh = new Mesh();
transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
transform.gameObject.active = true;
}
}
출처 - Unity Documentation 드로우 콜 배칭
출처 - Unity Documentation Mesh.CombineMeshes
출처 - [유니티 그래픽스 최적화] 04.드로우콜과 배칭
끗-!