CombineMeshes C# example badly written

Hell, it doesn’t even compile.
I tried a fix:

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]


public class CombineMeshes : 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,true);
        transform.gameObject.active = true;
    }
}

But that results in:

count <= std::numeric_limits<UInt16>::max()
UnityEngine.Mesh:CombineMeshes(CombineInstance[])
CombineMeshes:Start() (at Assets/Scripts/CombineMeshes.cs:20)

Also some very weird issues.

Never mind, there’s one included in the scripting package which does work. The error was caused because I had put it on an object that contained no meshes (or at least, not directly).

I just upgraded to Unity Pro and got the same error. Seemed to work fine before, but now the mesh is a bunch of gobily-goop. What scripting package are you talking about? How did you fix it?

edit:

nm found the package.

Where exactly is that package?

Look under Asset->Import Package->Scripts

MeshCombineUtility.cs

Looks like it’s removed from newer versions of the package with no replacement :confused: