本文整理汇总了C#中MeshData.AddVertices方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.AddVertices方法的具体用法?C# MeshData.AddVertices怎么用?C# MeshData.AddVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData.AddVertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlockData
public override MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
data.useRenderDataForCol = true;
Mesh mesh = GetCustomModel();
//Add the verticies, triangles, and uvs
data.AddTriangles(mesh.triangles, submesh);
data.AddVertices(mesh.vertices, mesh.normals, new Vector3(x, y - 0.5f, z), Quaternion.Euler(-90, 90 * rotation, 0));
data.AddUVs(mesh.uv);
return data;
}
示例2: RenderBlock
void RenderBlock(Block block) {
MeshData data = new MeshData();
block.BlockData(0, 0, 0, data, 0, new Block[,,] { { { block } } });
//Instantiate if it is a spawnable block
if (block is SpawnableBlock) {
SpawnableBlock b = (SpawnableBlock)block;
b.InstantiateBlock(transform, Vector3.zero, 0, 0, 0, new Block[,,] { { { } } });
b.transform.localScale = Vector3.one;
//Add verticies to meshdata for scaling
MeshFilter[] meshs = b.GetPrefab().GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter m in meshs) {
data.AddVertices(m.sharedMesh.vertices, m.sharedMesh.normals, m.transform.localPosition, m.transform.rotation);
}
//Set layer
foreach (Transform child in transform) {
child.gameObject.layer = 8;
}
}
data.Rotate(Quaternion.Euler(0, -90, 0));
//Scale
ScaleBlock(block, data);
//Clear mesh
filter.mesh.Clear();
//Verticies
filter.mesh.vertices = data.vertices.ToArray();
//Submeshes
filter.mesh.subMeshCount = data.triangles.Count;
for (int i = 0; i < data.triangles.Count; i++) {
filter.mesh.SetTriangles(data.triangles[i], i);
}
//UVs and normals
filter.mesh.uv = data.uvs.ToArray();
filter.mesh.normals = data.normals.ToArray();
//Material
meshRenderer.material = block.GetMaterial();
}