本文整理汇总了C#中UnityEngine.UI.VertexHelper.AddVert方法的典型用法代码示例。如果您正苦于以下问题:C# VertexHelper.AddVert方法的具体用法?C# VertexHelper.AddVert怎么用?C# VertexHelper.AddVert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.UI.VertexHelper
的用法示例。
在下文中一共展示了VertexHelper.AddVert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPopulateMesh
protected override void OnPopulateMesh(Mesh toFill)
{
Texture mainTexture = this.mainTexture;
if (mainTexture != null)
{
Vector4 zero = Vector4.zero;
int num = Mathf.RoundToInt(mainTexture.width * this.uvRect.width);
int num2 = Mathf.RoundToInt(mainTexture.height * this.uvRect.height);
float num3 = ((num & 1) != 0) ? ((float) (num + 1)) : ((float) num);
float num4 = ((num2 & 1) != 0) ? ((float) (num2 + 1)) : ((float) num2);
zero.x = 0f;
zero.y = 0f;
zero.z = ((float) num) / num3;
zero.w = ((float) num2) / num4;
zero.x -= base.rectTransform.pivot.x;
zero.y -= base.rectTransform.pivot.y;
zero.z -= base.rectTransform.pivot.x;
zero.w -= base.rectTransform.pivot.y;
zero.x *= base.rectTransform.rect.width;
zero.y *= base.rectTransform.rect.height;
zero.z *= base.rectTransform.rect.width;
zero.w *= base.rectTransform.rect.height;
using (VertexHelper helper = new VertexHelper())
{
Color color = base.color;
helper.AddVert(new Vector3(zero.x, zero.y), color, new Vector2(this.m_UVRect.xMin, this.m_UVRect.yMin));
helper.AddVert(new Vector3(zero.x, zero.w), color, new Vector2(this.m_UVRect.xMin, this.m_UVRect.yMax));
helper.AddVert(new Vector3(zero.z, zero.w), color, new Vector2(this.m_UVRect.xMax, this.m_UVRect.yMax));
helper.AddVert(new Vector3(zero.z, zero.y), color, new Vector2(this.m_UVRect.xMax, this.m_UVRect.yMin));
helper.AddTriangle(0, 1, 2);
helper.AddTriangle(2, 3, 0);
helper.FillMesh(toFill);
}
}
}
示例2: EditMesh
void EditMesh(VertexHelper vh)
{
vh.Clear();
int count = vertexInfoList.Count;
if (count < 3)
return;//3개서부터 보임
for (int n = 0; n < vertexInfoList.Count; n++)
{
vh.AddVert(getRadiusPosition(vertexInfoList[n], n), checkVertexColor(vertexInfoList[n].color) ,Vector2.zero);
}
if (!innerPolygon)
{
for (int n = 0; n < count - 2; n++)
{
vh.AddTriangle(0, n + 1, n + 2);
}
}
else
{
for (int n = 0; n < count; n++)
{
vh.AddVert(getRadiusPosition(vertexInfoList[n], n, width), checkVertexColor(vertexInfoList[n].color), Vector2.zero);
}
for (int n = 0; n < count; n++)
{
vh.AddTriangle(n, (n + 1) % count, count + (1 + n) % count);
vh.AddTriangle(n, n + count, count + (1 + n) % count);
}
}
}
示例3: AddQuad
private static void AddQuad(VertexHelper vh, Vector2 posMin, Vector2 posMax, Color32 color, Vector2 uvMin, Vector2 uvMax)
{
int currentVertCount = vh.currentVertCount;
vh.AddVert(new Vector3(posMin.x, posMin.y, 0f), color, new Vector2(uvMin.x, uvMin.y));
vh.AddVert(new Vector3(posMin.x, posMax.y, 0f), color, new Vector2(uvMin.x, uvMax.y));
vh.AddVert(new Vector3(posMax.x, posMax.y, 0f), color, new Vector2(uvMax.x, uvMax.y));
vh.AddVert(new Vector3(posMax.x, posMin.y, 0f), color, new Vector2(uvMax.x, uvMin.y));
vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
vh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount);
}
示例4: OnPopulateMesh
protected override void OnPopulateMesh(Mesh m)
{
Vector2 corner1 = new Vector2(0f, 0f);
Vector2 corner2 = new Vector2(1f, 1f);
corner1.x -= rectTransform.pivot.x;
corner1.y -= rectTransform.pivot.y;
corner2.x -= rectTransform.pivot.x;
corner2.y -= rectTransform.pivot.y;
corner1.x *= rectTransform.rect.width;
corner1.y *= rectTransform.rect.height;
corner2.x *= rectTransform.rect.width;
corner2.y *= rectTransform.rect.height;
Vector2 dc=corner2-corner1;
Vector4 uv = sprite == null ? Vector4.zero : DataUtility.GetOuterUV(sprite);
Vector2 uvz=new Vector2(uv.x, uv.y);
Vector2 duv=new Vector2(uv.z, uv.w)-uvz;
using (var vh = new VertexHelper())
{
float dx=1.0f/(float)(numdef);
int numer=0;
for(int yy=0;yy<numdef;yy++)
for(int xx=0;xx<numdef;xx++)
{
Vector2 c1 = corner1+new Vector2(xx*dc.x*dx, yy*dc.y*dx);
Vector2 c2 = corner1+new Vector2((xx+1)*dc.x,(yy+1)*dc.y)*dx;
float rx1=dx*xx;
float rx2=dx*(xx+1);
float ry1=dx*yy;
float ry2=dx*(yy+1);
rx1*=rx1;
rx2*=rx2;
ry1=Mathf.Sqrt(ry1);
ry2=Mathf.Sqrt(ry2);
Vector2 uv0 =uvz+new Vector2(rx1*duv.x,ry1*duv.y);
Vector2 uv1 =uvz+new Vector2(rx2*duv.x,ry2*duv.y);
vh.AddVert(new Vector3(c1.x, c1.y), color, uv0);
vh.AddVert(new Vector3(c1.x, c2.y), color, new Vector2(uv0.x, uv1.y));
vh.AddVert(new Vector3(c2.x, c2.y), color, uv1);
vh.AddVert(new Vector3(c2.x, c1.y), color, new Vector2(uv1.x, uv0.y));
vh.AddTriangle(0+numer*4, 1+numer*4, 2+numer*4);
vh.AddTriangle(2+numer*4, 3+numer*4, 0+numer*4);
numer++;
}
vh.FillMesh(m);
}
}
示例5: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper vh) {
if (this.mesh == null) return;
var color32 = this.color;
vh.Clear();
var vs = this.mesh.vertices;
for (int i = 0; i < vs.Length; ++i) {
var v = vs[i];
vh.AddVert(new Vector3(v.x, v.y), color32, Vector2.zero);
}
var ts = this.mesh.triangles;
for (int i = 0; i < ts.Length; i += 3) {
var t1 = ts[i];
var t2 = ts[i + 1];
var t3 = ts[i + 2];
vh.AddTriangle(t1, t2, t3);
}
}
示例6: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper vh)
{
Texture mainTexture = this.mainTexture;
vh.Clear();
if (mainTexture != null)
{
Rect pixelAdjustedRect = base.GetPixelAdjustedRect();
Vector4 vector = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + pixelAdjustedRect.width, pixelAdjustedRect.y + pixelAdjustedRect.height);
float num = mainTexture.width * mainTexture.texelSize.x;
float num2 = mainTexture.height * mainTexture.texelSize.y;
Color color = this.color;
vh.AddVert(new Vector3(vector.x, vector.y), color, new Vector2(this.m_UVRect.xMin * num, this.m_UVRect.yMin * num2));
vh.AddVert(new Vector3(vector.x, vector.w), color, new Vector2(this.m_UVRect.xMin * num, this.m_UVRect.yMax * num2));
vh.AddVert(new Vector3(vector.z, vector.w), color, new Vector2(this.m_UVRect.xMax * num, this.m_UVRect.yMax * num2));
vh.AddVert(new Vector3(vector.z, vector.y), color, new Vector2(this.m_UVRect.xMax * num, this.m_UVRect.yMin * num2));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
}
}
示例7: GenerateSimpleSprite
private void GenerateSimpleSprite(VertexHelper vh, bool lPreserveAspect)
{
Vector4 drawingDimensions = this.GetDrawingDimensions(lPreserveAspect);
Vector4 vector2 = (this.activeSprite == null) ? Vector4.zero : DataUtility.GetOuterUV(this.activeSprite);
Color color = this.color;
vh.Clear();
vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.y), color, new Vector2(vector2.x, vector2.y));
vh.AddVert(new Vector3(drawingDimensions.x, drawingDimensions.w), color, new Vector2(vector2.x, vector2.w));
vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.w), color, new Vector2(vector2.z, vector2.w));
vh.AddVert(new Vector3(drawingDimensions.z, drawingDimensions.y), color, new Vector2(vector2.z, vector2.y));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
}
示例8: OnPopulateMesh
/// <summary>
/// Fill the vertex buffer data.
/// </summary>
protected virtual void OnPopulateMesh(VertexHelper vh)
{
var r = GetPixelAdjustedRect();
var v = new Vector4(r.x, r.y, r.x + r.width, r.y + r.height);
Color32 color32 = color;
vh.Clear();
vh.AddVert(new Vector3(v.x, v.y), color32, new Vector2(0f, 0f));
vh.AddVert(new Vector3(v.x, v.w), color32, new Vector2(0f, 1f));
vh.AddVert(new Vector3(v.z, v.w), color32, new Vector2(1f, 1f));
vh.AddVert(new Vector3(v.z, v.y), color32, new Vector2(1f, 0f));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
}
示例9: OnPopulateMesh
protected virtual void OnPopulateMesh(Mesh m)
{
Rect pixelAdjustedRect = this.GetPixelAdjustedRect();
Vector4 vector = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + pixelAdjustedRect.width, pixelAdjustedRect.y + pixelAdjustedRect.height);
Color32 color = this.color;
using (VertexHelper helper = new VertexHelper())
{
helper.AddVert(new Vector3(vector.x, vector.y), color, new Vector2(0f, 0f));
helper.AddVert(new Vector3(vector.x, vector.w), color, new Vector2(0f, 1f));
helper.AddVert(new Vector3(vector.z, vector.w), color, new Vector2(1f, 1f));
helper.AddVert(new Vector3(vector.z, vector.y), color, new Vector2(1f, 0f));
helper.AddTriangle(0, 1, 2);
helper.AddTriangle(2, 3, 0);
helper.FillMesh(m);
}
}
示例10: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper vh)
{
Texture mainTexture = this.mainTexture;
vh.Clear();
if (!((Object) mainTexture != (Object) null))
return;
Rect pixelAdjustedRect = this.GetPixelAdjustedRect();
Vector4 vector4 = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + pixelAdjustedRect.width, pixelAdjustedRect.y + pixelAdjustedRect.height);
Color color = this.color;
vh.AddVert(new Vector3(vector4.x, vector4.y), (Color32) color, new Vector2(this.m_UVRect.xMin, this.m_UVRect.yMin));
vh.AddVert(new Vector3(vector4.x, vector4.w), (Color32) color, new Vector2(this.m_UVRect.xMin, this.m_UVRect.yMax));
vh.AddVert(new Vector3(vector4.z, vector4.w), (Color32) color, new Vector2(this.m_UVRect.xMax, this.m_UVRect.yMax));
vh.AddVert(new Vector3(vector4.z, vector4.y), (Color32) color, new Vector2(this.m_UVRect.xMax, this.m_UVRect.yMin));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
}
示例11: AddQuad
static void AddQuad(VertexHelper vertexHelper, Vector3[] quadPositions, Color32 color, Vector3[] quadUVs)
{
int startIndex = vertexHelper.currentVertCount;
for (int i = 0; i < 4; ++i)
vertexHelper.AddVert(quadPositions[i], color, quadUVs[i]);
vertexHelper.AddTriangle(startIndex, startIndex + 1, startIndex + 2);
vertexHelper.AddTriangle(startIndex + 2, startIndex + 3, startIndex);
}
示例12: OnPopulateMesh
protected override void OnPopulateMesh(Mesh m)
{
var Points = new List<Vector2>();
if (Decay < 0.0f)
Decay = 0.0f;
if (Decay > 1.0f)
Decay = 1.0f;
if (Gamma < 0.1f)
Gamma = 0.1f;
if (Gamma > 10.0f)
Gamma = 10.0f;
for (int i = 0; i < CurveResolution; i++)
{
float zeroOne = (float) i/(float) (CurveResolution - 1);
float v = Mathf.Pow(zeroOne, Gamma) * Decay;
Points.Add(new Vector2((float) i / (float) (CurveResolution - 1), 1.0f - v));
}
var sizeX = rectTransform.rect.width;
var sizeY = rectTransform.rect.height;
var offsetX = -rectTransform.pivot.x * rectTransform.rect.width;
var offsetY = -rectTransform.pivot.y * rectTransform.rect.height;
if (UseMargins)
{
sizeX -= Margin.x;
sizeY -= Margin.y;
offsetX += Margin.x / 2f;
offsetY += Margin.y / 2f;
}
var vh = new VertexHelper();
for (int i = 0; i < Points.Count-1; i++)
{
var prev = Points[i];
var cur = Points[i+1];
prev = new Vector2(prev.x * sizeX + offsetX, prev.y * sizeY + offsetY);
cur = new Vector2(cur.x * sizeX + offsetX, cur.y * sizeY + offsetY);
var normal = new Vector3(cur.x - prev.x, cur.y - prev.y);
var perp_vector = Vector3.Cross(normal, Vector3.forward).normalized;
var halfThikness = LineThikness/2;
var v1 = prev + new Vector2(perp_vector.x * -halfThikness, perp_vector.y * -halfThikness);
var v2 = prev + new Vector2(perp_vector.x * halfThikness, perp_vector.y * halfThikness);
var v3 = cur + new Vector2(perp_vector.x * halfThikness, perp_vector.y * halfThikness);
var v4 = cur + new Vector2(perp_vector.x * -halfThikness, perp_vector.y * -halfThikness);
vh.AddVert(v1, color, new Vector2(0f, 0f));
vh.AddVert(v2, color, new Vector2(0f, 1f));
vh.AddVert(v3, color, new Vector2(1f, 1f));
vh.AddVert(v4, color, new Vector2(1f, 0f));
vh.AddTriangle(0 + i*4, 1 + i * 4, 2 + i * 4);
vh.AddTriangle(2 + i * 4, 3 + i * 4, 0 + i * 4);
}
vh.FillMesh(m);
}
示例13: OnPopulateMesh
/// <summary>
/// <para>Callback function when a UI element needs to generate vertices.</para>
/// </summary>
/// <param name="m">Mesh to populate with UI data.</param>
/// <param name="vh"></param>
protected virtual void OnPopulateMesh(VertexHelper vh)
{
Rect pixelAdjustedRect = this.GetPixelAdjustedRect();
Vector4 vector4 = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + pixelAdjustedRect.width, pixelAdjustedRect.y + pixelAdjustedRect.height);
Color32 color = (Color32) this.color;
vh.Clear();
vh.AddVert(new Vector3(vector4.x, vector4.y), color, new Vector2(0.0f, 0.0f));
vh.AddVert(new Vector3(vector4.x, vector4.w), color, new Vector2(0.0f, 1f));
vh.AddVert(new Vector3(vector4.z, vector4.w), color, new Vector2(1f, 1f));
vh.AddVert(new Vector3(vector4.z, vector4.y), color, new Vector2(1f, 0.0f));
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(2, 3, 0);
}
示例14: ModifyVertices
private void ModifyVertices(VertexHelper vh)
{
List<UIVertex> verts = new List<UIVertex>(vh.currentVertCount);
vh.GetUIVertexStream(verts);
vh.Clear();
int step = 6;
for (int i = 0; i < verts.Count; i += step) {
//6 point
var tl = multiplyColor(verts[i+0], colorTop);
var tr = multiplyColor (verts [i+1], colorTop);
var bl = multiplyColor (verts [i+4], colorBottom);
var br = multiplyColor (verts [i + 3], colorBottom);
var cl = calcCenterVertex(verts[i+0], verts [i+4]);
var cr = calcCenterVertex (verts [i+1], verts [i+2]);
vh.AddVert (tl);
vh.AddVert (tr);
vh.AddVert (cr);
vh.AddVert (cr);
vh.AddVert (cl);
vh.AddVert (tl);
vh.AddVert (cl);
vh.AddVert (cr);
vh.AddVert (br);
vh.AddVert (br);
vh.AddVert (bl);
vh.AddVert (cl);
}
for (int i = 0; i < vh.currentVertCount; i += 12) {
vh.AddTriangle (i + 0, i + 1, i + 2);
vh.AddTriangle (i + 3, i + 4, i + 5);
vh.AddTriangle (i + 6, i + 7, i + 8);
vh.AddTriangle (i + 9, i + 10, i + 11);
}
}
示例15: FillJoint
void FillJoint( VertexHelper vh, UIVertex vp0, UIVertex vp1, UIVertex[] prvLineVert, Color color)
{
Vector3 forwardWidthVector = vp1.position - vp0.position;
Vector3 prvWidthVector = prvLineVert[1].position - prvLineVert[0].position;
Vector3 prvVector = Vector3.Cross(prvWidthVector, new Vector3(0, 0, 1));
Vector3 p0;
Vector3 p1;
Vector3 center = (vp0.position + vp1.position) / 2f;
if(Vector3.Dot(prvVector, forwardWidthVector) > 0)
{
p0 = vp1.position;
p1 = prvLineVert[1].position;
}
else
{
p0 = vp0.position;
p1 = prvLineVert[0].position;
}
Vector3 cp0 = (p0 + p1- center*2).normalized * width *0.5f + center;
float angle = Vector3.Angle(p0 - center, p1 - center);
int currentVert = vh.currentVertCount;
int divideCount = (int)(angle / fillDivideAngle);
if(divideCount == 0) { divideCount = 1; }
float unit = 1f / divideCount;
vh.AddVert(center, color, Vector2.zero);
vh.AddVert(p0, color, Vector2.zero);
for (int n = 0; n < divideCount; n++)
{
vh.AddVert(Curve.CalculateBezier(p0, p1, cp0, unit *(n+1)), color, Vector2.zero);
vh.AddTriangle(currentVert, currentVert + 1 + n, currentVert + 2 + n);
}
}