本文整理汇总了C#中MeshData.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.Expand方法的具体用法?C# MeshData.Expand怎么用?C# MeshData.Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData.Expand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderCursor
void RenderCursor() {
MeshData data = new MeshData();
blockTypes.Clear();
for (int x = 0; x < block.GetLength(0); x++) {
for (int y = 0; y < block.GetLength(1); y++) {
for (int z = 0; z < block.GetLength(2); z++) {
if (block[x, y, z].GetName() != "Air" && !(block[x, y, z] is SpawnableBlock)) {
//Try to find if the block type already exists in chunk
int submesh = blockTypes.IndexOf(block[x, y, z].GetName());
//If there are no blocks with its type, add it
if (submesh == -1) {
blockTypes.Add(block[x, y, z].GetName());
submesh = blockTypes.Count - 1;
}
data = block[x, y, z].BlockData(x, y, z, data, submesh, block);
}
}
}
}
data.Offset(-offset);
//Expand to prevent z-fighting
data.Expand(0.001f);
//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();
//Materials
Material[] materials = new Material[filter.mesh.subMeshCount];
for (int i = 0; i < materials.Length; i++) {
materials[i] = BlockManager.GetBlock(blockTypes[i]).GetMaterial();
}
meshRenderer.materials = materials;
}