代码语言:javascript复制
using UnityEngine;
using System.Collections;
public class AutoAddCollision : MonoBehaviour {
// Use this for initialization
void Start () {
ModelAddMeshCollider();
}
void ModelAddMeshCollider()
{
foreach (var render in transform.GetComponentsInChildren<MeshRenderer>())
{
render.gameObject.AddComponent<MeshCollider>();
}
}
}