メッシュの頂点とUVを設定する必要があります。 ここには、単一の平面を作成する例があります。 xpos、ypos、zposをあなたの望むポイントの座標で置き換える必要があります。
GameObject plane = new GameObject("Plane");
MeshFilter meshFilter = (MeshFilter)plane.AddComponent(typeof(MeshFilter));
Mesh mymesh = new Mesh();
mymesh.name = "MyCustomMesh";
mymesh.vertices = new Vector3[] {
new Vector3(xpos, ypos, zpos),
new Vector3(xpos, ypos, zpos),
new Vector3(xpos, ypos, zpos),
new Vector3(xpos, ypos, zpos),
};
mymesh.uv = new Vector2[] {
new Vector2 (0, 0),
new Vector2 (0, 1),
new Vector2(1, 1),
new Vector2 (1, 0)
};
mymesh.triangles = new int[] { 0, 1, 2, 0, 2, 3};
mymesh.RecalculateNormals();
meshFilter.mesh = mymesh;
MeshRenderer renderer = plane.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
メッシュに 'mesh'プロパティを設定する必要があります。 – Draco18s
メッシュコライダーが使用するメッシュを設定する - > 'GetComponent()。sharedMesh = mesh;' https://docs.unity3d.com/ScriptReference/MeshCollider-sharedMesh.html –
yes