MeshCollider.sharedMesh 共享网格

var sharedMesh : Mesh

Description描述

The mesh object used for collision detection

用于检测的网格物体。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Mesh meshToCollide;
	public void Awake() {
		if (!typeof(meshToCollide)) {
			Debug.LogError("Assign a mesh in the inspector");
			return;
		}
		transform.gameObject.AddComponent<MeshCollider>();
		transform.GetComponent<MeshCollider>().sharedMesh = meshToCollide;
	}
}
// Assigns an arbitrary mesh collider to the current transform
// 赋予一个任意的网格碰撞器给当前的transform。
var meshToCollide : Mesh;

if(!meshToCollide) {
	Debug.LogError("Assign a mesh in the inspector");
	return;
}
transform.gameObject.AddComponent(MeshCollider);
transform.GetComponent(MeshCollider).sharedMesh = meshToCollide;
Page last updated: 2010-12-12