本文整理汇总了C#中Vector3.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Convert方法的具体用法?C# Vector3.Convert怎么用?C# Vector3.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Convert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePolygon
void UpdatePolygon()
{
MeshFilter.sharedMesh = mesh;
if (mesh == null)
return;
mesh.Clear();
var vertices = new Vector3[2 * Slices + 1];
var triangles = new int[Slices * 3];
for (int i = 0; i < Slices; i++)
{
int verticesIndex = i * 2;
float halfAngle = (360f / Slices * fillRatio) / 2;
vertices[verticesIndex] = Vector2.up.Rotate(i * (360f / Slices) - halfAngle);
vertices[verticesIndex + 1] = Vector2.up.Rotate(i * (360f / Slices) + halfAngle);
triangles[i * 3] = Slices * 2;
triangles[i * 3 + 1] = verticesIndex;
triangles[i * 3 + 2] = (verticesIndex + 1);
}
mesh.vertices = vertices;
mesh.uv = vertices.Convert(v => v.ToVector2());
mesh.triangles = triangles;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
mesh.Optimize();
}
示例2: UpdatePolygon
void UpdatePolygon()
{
MeshFilter.sharedMesh = mesh;
if (mesh == null)
return;
mesh.Clear();
var vertices = new Vector3[Sides + 1];
var triangles = new int[Sides * 3];
for (int i = 0; i < Sides; i++)
{
vertices[i] = Vector2.up.Rotate(i * (360f / Sides));
triangles[i * 3] = Sides;
triangles[i * 3 + 1] = i;
triangles[i * 3 + 2] = (i + 1) % Sides;
}
mesh.vertices = vertices;
mesh.uv = vertices.Convert(v => v.ToVector2());
mesh.triangles = triangles;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
mesh.Optimize();
}