本文整理汇总了C#中UnityEngine.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# UnityEngine.Clear方法的具体用法?C# UnityEngine.Clear怎么用?C# UnityEngine.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine
的用法示例。
在下文中一共展示了UnityEngine.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPopulateMesh
protected override void OnPopulateMesh(UnityEngine.UI.VertexHelper vh)
{
if (!HollowRect) return;
Color32 color32 = color;
vh.Clear();
Rect innerRect = new Rect(pos, size);
Rect outerRect = GetPixelAdjustedRect();
AddQuad(vh, new Vector2(outerRect.xMin, outerRect.yMax), new Vector2(outerRect.xMax, innerRect.center.y), color);
AddQuad(vh, new Vector2(outerRect.xMin, innerRect.center.y), new Vector2(HollowRect.anchoredPosition.x - innerRect.width/2, HollowRect.anchoredPosition.y - innerRect.height/2), color);
AddQuad(vh, new Vector2(HollowRect.anchoredPosition.x + innerRect.width / 2, innerRect.center.y), new Vector2(outerRect.xMax, HollowRect.anchoredPosition.y - innerRect.height/2), color);
AddQuad(vh, new Vector2(outerRect.xMin, HollowRect.anchoredPosition.y - innerRect.height / 2), new Vector2(outerRect.xMax, -outerRect.yMax), color);
}
示例2: Bind
/// Collect and bind geometry from stream
public void Bind(UnityEngine.Mesh mesh)
{
var vertices = new List<Vector3>();
var triangles = new List<int>();
var uv = useUV ? new List<Vector2>() : null;
var color = useColor ? new List<Color32>() : null;
var normals = useUV ? new List<Vector3>() : null;
// Collect
foreach (var gp in geometry.Geometry)
{
gp.VertexOffset = vertices.Count;
vertices.AddRange(gp.Vertices);
triangles.AddRange(gp.Triangles);
if (uv != null) { uv.AddRange(gp.UV); }
if (color != null) { color.AddRange(gp.Color); }
if (normals != null) { normals.AddRange(gp.Normals); }
}
// Attach
mesh.Clear();
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();
if (useUV) { mesh.uv = uv.ToArray(); }
if (useColor) { mesh.colors32 = color.ToArray(); }
if (useNormals) { mesh.normals = normals.ToArray(); }
// Bind
if (!useNormals) { mesh.RecalculateNormals(); }
mesh.RecalculateBounds();
mesh.Optimize();
// Summary
vertexGen = vertices.Count;
triangleGen = triangles.Count;
}
示例3: OnPopulateMesh
protected override void OnPopulateMesh(UnityEngine.UI.VertexHelper vh)
{
if (buffer.modified) {
buffer.modified = false;
vh.Clear();
int count = rectangleCount * 4;
List<UIVertex> vertices = new List<UIVertex>();
for (int i = 0; i < count; i += 4) {
vertices.Add(buffer.vertices[i + 0]);
vertices.Add(buffer.vertices[i + 1]);
vertices.Add(buffer.vertices[i + 2]);
vertices.Add(buffer.vertices[i + 2]);
vertices.Add(buffer.vertices[i + 3]);
vertices.Add(buffer.vertices[i + 0]);
}
vh.AddUIVertexTriangleStream(vertices);
}
}
示例4: MakeMesh
public static void MakeMesh(UnityEngine.Mesh mesh, Face face, int vertices_begin, int vertices_end, int indices_begin, int indices_end, int indices_offset)
{
//we have to clear the mesh first, otherwise there will be exceptions.
mesh.Clear();
int vertices_count = vertices_end - vertices_begin + 1;
UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertices_count];
UnityEngine.Vector3[] normals = new UnityEngine.Vector3[vertices_count];
UnityEngine.Vector2[] uv = new UnityEngine.Vector2[vertices_count];
for (int k = vertices_begin, i = 0; k <= vertices_end; ++k, ++i)
{
vertices[i].x = face.Vertices[k].Position.X;
vertices[i].y = face.Vertices[k].Position.Y;
//HACK: unity3d uses left-hand coordinate, so we have to mirror z corrd
vertices[i].z = -face.Vertices[k].Position.Z;
normals[i].x = face.Vertices[k].Normal.X;
normals[i].y = face.Vertices[k].Normal.Y;
//HACK: unity3d uses left-hand coordinate, so we have to mirror z corrd
normals[i].z = -face.Vertices[k].Normal.Z;
uv[i].x = face.Vertices[k].TexCoord.X;
//HACK: unity3d uses left-bottom corner as the origin of the texture
uv[i].y = 1 - face.Vertices[k].TexCoord.Y;
}
//indices for this face
int[] triangles = new int[indices_end - indices_begin + 1];
for (int k = indices_begin, i = 0; k <= indices_end; k += 3, i += 3)
{
//HACK: OpenGL's default front face is counter-clock-wise
triangles[i] = face.Indices[k + 2] - indices_offset;
triangles[i + 1] = face.Indices[k + 1] - indices_offset;
triangles[i + 2] = face.Indices[k + 0] - indices_offset;
}
mesh.vertices = vertices;
mesh.normals = normals;
mesh.uv = uv;
mesh.triangles = triangles;
}