Using the old CombineChildren, adding a mesh collider works as expected.
Using the script Eric5h5 made with CombineMeshes(), when you add a mesh collider it will automatically use the mesh in the filter, as expected. You can even double click it in the inspector and see the mesh. But it will not work as a collider.
Test:
Make 1 empty GO
make 2 boxes, remove box colliders make them children to GO
add script for combine meshes or CombineChildren
add a script that does something when clicking on GO
run
Drop a mesh collider on the parent
clicking on the combine meshes version will do nothing
Clicking on the CombineChildren version will work
I dont think this is a problem with the script for combine meshes, unless it needs something added.
I think this is a problem with the way CombineMeshes works. I dont have access to source and probably wouldnt know what to look for anyway.
I did try adding
RecalculateNormals();
RecalculateBounds();
after the combine, just to see what happened but it didnt help.
Combine3.js
// This script should be put on an empty GameObject
// Objects to be combined should be children of the empty GameObject
@script RequireComponent(MeshFilter)
@script RequireComponent(MeshRenderer)
function Start () {
for (var child in transform)
child.position += transform.position;
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
var meshFilters = GetComponentsInChildren(MeshFilter);
var combine : CombineInstance[] = new CombineInstance[meshFilters.Length-1];
var index = 0;
for (var i = 0; i < meshFilters.Length; i++)
{
if (meshFilters[i].sharedMesh == null) continue;
combine[index].mesh = meshFilters[i].sharedMesh;
combine[index++].transform = meshFilters[i].transform.localToWorldMatrix;
meshFilters[i].renderer.enabled = false;
}
GetComponent(MeshFilter).mesh = new Mesh();
GetComponent(MeshFilter).mesh.CombineMeshes (combine);
renderer.material = meshFilters[1].renderer.sharedMaterial;
}
Make objects go up(LMB) or down (ctrl LMB)
EditElev.cs
using UnityEngine;
using System.Collections;
public class EditElev : MonoBehaviour {
// Use this for initialization
void Start () {
}
public void OnMouseDown()
{
if(Input.GetKey( KeyCode.LeftControl ) ) //DOWN
{
transform.position += new Vector3(0, -.08f, 0);
}
else
{
transform.position += new Vector3(0, .08f, 0); //UP
}
}
}