Combine meshes in Unity

Do you want to combine meshes into one single mesh in Unity? This tutorial explains how to use unity's CombineMeshes function to do that.


using System.Collections.Generic;
using UnityEngine;

public class App : MonoBehaviour
    public Mesh Mesh1;
    public Mesh Mesh2;

    private void Start()
        var mesh = CombineMeshes(new List<Mesh> { Mesh1, Mesh2 });
        GetComponent<MeshFilter>().mesh = mesh;

    private Mesh CombineMeshes(List<Mesh> meshes)
        var combine = new CombineInstance[meshes.Count];
        for (int i = 0; i < meshes.Count; i++)
            combine[i].mesh = meshes[i];
            combine[i].transform = transform.localToWorldMatrix;

        var mesh = new Mesh();
        return mesh;


Written by Loek van den Ouweland on December 01, 2017. Questions regarding this artice? You can send them to the address below.
By using this site, you acknowledge that you have read and understand our Cookie and Privacy Policy.