本文整理汇总了C#中UnityEngine.UI.VertexHelper.FillMesh方法的典型用法代码示例。如果您正苦于以下问题:C# VertexHelper.FillMesh方法的具体用法?C# VertexHelper.FillMesh怎么用?C# VertexHelper.FillMesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.UI.VertexHelper
的用法示例。
在下文中一共展示了VertexHelper.FillMesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModifyMesh
public override void ModifyMesh(Mesh mesh)
{
if (this.IsActive())
{
List<UIVertex> stream = new List<UIVertex>();
using (VertexHelper helper = new VertexHelper(mesh))
{
helper.GetUIVertexStream(stream);
}
int num = stream.Count * 5;
if (stream.Capacity < num)
{
stream.Capacity = num;
}
int start = 0;
int count = stream.Count;
base.ApplyShadowZeroAlloc(stream, base.effectColor, start, stream.Count, base.effectDistance.x, base.effectDistance.y);
start = count;
count = stream.Count;
base.ApplyShadowZeroAlloc(stream, base.effectColor, start, stream.Count, base.effectDistance.x, -base.effectDistance.y);
start = count;
count = stream.Count;
base.ApplyShadowZeroAlloc(stream, base.effectColor, start, stream.Count, -base.effectDistance.x, base.effectDistance.y);
start = count;
count = stream.Count;
base.ApplyShadowZeroAlloc(stream, base.effectColor, start, stream.Count, -base.effectDistance.x, -base.effectDistance.y);
using (VertexHelper helper2 = new VertexHelper())
{
helper2.AddUIVertexTriangleStream(stream);
helper2.FillMesh(mesh);
}
}
}
示例2: 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);
}
}
}
示例3: ModifyMesh
public override void ModifyMesh(Mesh mesh) {
if (this.IsActive() == false) {
return;
}
var list = new List<UIVertex>();
using (var vertexHelper = new VertexHelper(mesh)) {
vertexHelper.GetUIVertexStream(list);
}
this.ModifyVertices(list); // calls the old ModifyVertices which was used on pre 5.2
using (var vertexHelper = new VertexHelper()) {
vertexHelper.AddUIVertexTriangleStream(list);
vertexHelper.FillMesh(mesh);
}
}
示例4: ModifyMesh
/// <summary>
/// <para>See:IMeshModifier.</para>
/// </summary>
/// <param name="mesh"></param>
public virtual void ModifyMesh(Mesh mesh)
{
using (VertexHelper helper = new VertexHelper(mesh))
{
this.ModifyMesh(helper);
helper.FillMesh(mesh);
}
}
示例5: ModifyMesh
/// <summary>
///
/// <para>
/// See:IMeshModifier.
/// </para>
///
/// </summary>
/// <param name="mesh"/>
public virtual void ModifyMesh(Mesh mesh)
{
using (VertexHelper vh = new VertexHelper(mesh))
{
this.ModifyMesh(vh);
vh.FillMesh(mesh);
}
}
示例6: ModifyMesh
public void ModifyMesh(Mesh mesh)
{
using (var vh = new VertexHelper(mesh))
{
EditMesh(vh);
vh.FillMesh(mesh);
}
}
示例7: ModifyMesh
public override void ModifyMesh(Mesh mesh)
{
if (!this.IsActive())
return;
using (var vh = new VertexHelper(mesh))
{
ModifyMesh(vh);
vh.FillMesh(mesh);
}
}
示例8: 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);
}
}
示例9: ModifyMesh
public override void ModifyMesh(Mesh mesh)
{
if (this.IsActive())
{
List<UIVertex> stream = new List<UIVertex>();
using (VertexHelper helper = new VertexHelper(mesh))
{
helper.GetUIVertexStream(stream);
}
this.ApplyShadow(stream, this.effectColor, 0, stream.Count, this.effectDistance.x, this.effectDistance.y);
using (VertexHelper helper2 = new VertexHelper())
{
helper2.AddUIVertexTriangleStream(stream);
helper2.FillMesh(mesh);
}
}
}
示例10: ModifyMesh
public override void ModifyMesh(Mesh mesh)
{
if (!this.IsActive())
return;
List<UIVertex> list = new List<UIVertex>();
using (VertexHelper vertexHelper = new VertexHelper(mesh)) {
vertexHelper.GetUIVertexStream(list);
}
ModifyVertices(list);
using (VertexHelper vertexHelper2 = new VertexHelper()) {
vertexHelper2.AddUIVertexTriangleStream(list);
vertexHelper2.FillMesh(mesh);
}
}
示例11: ModifyMesh
public void ModifyMesh(Mesh mesh)
{
if (!this.enabled)
return;
List<UIVertex> list = new List<UIVertex>();
using (VertexHelper vertexHelper = new VertexHelper(mesh))
{
vertexHelper.GetUIVertexStream(list);
}
ModifyVertices(list); // calls the old ModifyVertices which was used on pre 5.2
using (VertexHelper vertexHelper2 = new VertexHelper())
{
vertexHelper2.AddUIVertexTriangleStream(list);
vertexHelper2.FillMesh(mesh);
}
}
示例12: 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);
}
}
示例13: OnPopulateMesh
protected override void OnPopulateMesh(Mesh toFill)
{
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
float inner = -rectTransform.pivot.x * rectTransform.rect.width + thickness;
toFill.Clear();
var vbo = new VertexHelper(toFill);
Vector2 prevX = Vector2.zero;
Vector2 prevY = Vector2.zero;
Vector2 uv0 = new Vector2(0, 0);
Vector2 uv1 = new Vector2(0, 1);
Vector2 uv2 = new Vector2(1, 1);
Vector2 uv3 = new Vector2(1, 0);
Vector2 pos0;
Vector2 pos1;
Vector2 pos2;
Vector2 pos3;
float f = (fillPercent / 100f);
float degrees = 360f / segments;
int fa = (int)((segments + 1) * f);
for (int i = -1 - (fa / 2); i < fa / 2 + 1; i++)
{
float rad = Mathf.Deg2Rad * (i * degrees);
float c = Mathf.Cos(rad);
float s = Mathf.Sin(rad);
uv0 = new Vector2(0, 1);
uv1 = new Vector2(1, 1);
uv2 = new Vector2(1, 0);
uv3 = new Vector2(0, 0);
pos0 = prevX;
pos1 = new Vector2(outer * c, outer * s);
if (fill)
{
pos2 = Vector2.zero;
pos3 = Vector2.zero;
}
else
{
pos2 = new Vector2(inner * c, inner * s);
pos3 = prevY;
}
prevX = pos1;
prevY = pos2;
vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
}
if (vbo.currentVertCount > 3)
{
vbo.FillMesh(toFill);
}
}
示例14: OnPopulateMesh
protected override void OnPopulateMesh(Mesh toFill)
{
if (this.font != null)
{
this.m_DisableFontTextureRebuiltCallback = true;
Vector2 size = base.rectTransform.rect.size;
TextGenerationSettings generationSettings = this.GetGenerationSettings(size);
this.cachedTextGenerator.Populate(this.text, generationSettings);
Rect rect = base.rectTransform.rect;
Vector2 textAnchorPivot = GetTextAnchorPivot(this.m_FontData.alignment);
Vector2 zero = Vector2.zero;
zero.x = (textAnchorPivot.x != 1f) ? rect.xMin : rect.xMax;
zero.y = (textAnchorPivot.y != 0f) ? rect.yMax : rect.yMin;
Vector2 vector4 = base.PixelAdjustPoint(zero) - zero;
IList<UIVertex> verts = this.cachedTextGenerator.verts;
float num = 1f / this.pixelsPerUnit;
int num2 = verts.Count - 4;
using (VertexHelper helper = new VertexHelper())
{
if (vector4 != Vector2.zero)
{
for (int i = 0; i < num2; i++)
{
int index = i & 3;
this.m_TempVerts[index] = verts[i];
this.m_TempVerts[index].position = (Vector3) (this.m_TempVerts[index].position * num);
this.m_TempVerts[index].position.x += vector4.x;
this.m_TempVerts[index].position.y += vector4.y;
if (index == 3)
{
helper.AddUIVertexQuad(this.m_TempVerts);
}
}
}
else
{
for (int j = 0; j < num2; j++)
{
int num6 = j & 3;
this.m_TempVerts[num6] = verts[j];
this.m_TempVerts[num6].position = (Vector3) (this.m_TempVerts[num6].position * num);
if (num6 == 3)
{
helper.AddUIVertexQuad(this.m_TempVerts);
}
}
}
helper.FillMesh(toFill);
}
this.m_DisableFontTextureRebuiltCallback = false;
}
}
示例15: OnPopulateMesh
protected override void OnPopulateMesh(Mesh toFill)
{
if (font == null)
return;
// We don't care if we the font Texture changes while we are doing our Update.
// The end result of cachedTextGenerator will be valid for this instance.
// Otherwise we can get issues like Case 619238.
m_DisableFontTextureRebuiltCallback = true;
Vector2 extents = rectTransform.rect.size;
var settings = GetGenerationSettings(extents);
cachedTextGenerator.Populate(text, settings);
Rect inputRect = rectTransform.rect;
// get the text alignment anchor point for the text in local space
Vector2 textAnchorPivot = GetTextAnchorPivot(m_FontData.alignment);
Vector2 refPoint = Vector2.zero;
refPoint.x = (textAnchorPivot.x == 1 ? inputRect.xMax : inputRect.xMin);
refPoint.y = (textAnchorPivot.y == 0 ? inputRect.yMin : inputRect.yMax);
// Determine fraction of pixel to offset text mesh.
Vector2 roundingOffset = PixelAdjustPoint(refPoint) - refPoint;
// Apply the offset to the vertices
IList<UIVertex> verts = cachedTextGenerator.verts;
float unitsPerPixel = 1 / (pixelsPerUnit);
//Last 4 verts are always a new line...
int vertCount = verts.Count - 4;
using (var vh = new VertexHelper())
{
if (roundingOffset != Vector2.zero)
{
for (int i = 0; i < vertCount; ++i)
{
int tempVertsIndex = i & 3;
m_TempVerts[tempVertsIndex] = verts[i];
m_TempVerts[tempVertsIndex].position *= unitsPerPixel;
m_TempVerts[tempVertsIndex].position.x += roundingOffset.x;
m_TempVerts[tempVertsIndex].position.y += roundingOffset.y;
if (tempVertsIndex == 3)
vh.AddUIVertexQuad(m_TempVerts);
}
}
else
{
for (int i = 0; i < vertCount; ++i)
{
int tempVertsIndex = i & 3;
m_TempVerts[tempVertsIndex] = verts[i];
m_TempVerts[tempVertsIndex].position *= unitsPerPixel;
if (tempVertsIndex == 3)
vh.AddUIVertexQuad(m_TempVerts);
}
}
vh.FillMesh(toFill);
}
m_DisableFontTextureRebuiltCallback = false;
}