本文整理汇总了C#中UnityEngine.UI.VertexHelper.AddUIVertexQuad方法的典型用法代码示例。如果您正苦于以下问题:C# VertexHelper.AddUIVertexQuad方法的具体用法?C# VertexHelper.AddUIVertexQuad怎么用?C# VertexHelper.AddUIVertexQuad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.UI.VertexHelper
的用法示例。
在下文中一共展示了VertexHelper.AddUIVertexQuad方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper vh)
{
var outer = -rectTransform.pivot.x * rectTransform.rect.width;
var inner = -rectTransform.pivot.x * rectTransform.rect.width + thickness;
vh.Clear();
var vert = UIVertex.simpleVert;
var prevX = Vector2.zero;
var prevY = Vector2.zero;
var uv0 = new Vector2(0, 0);
var uv1 = new Vector2(0, 1);
var uv2 = new Vector2(1, 1);
var uv3 = new Vector2(1, 0);
Vector2 pos0;
Vector2 pos1;
Vector2 pos2;
Vector2 pos3;
var degrees = 360f / segments;
var fillAngle = (int)((segments + 1) * fillPercent);
for (int i = 0; i < fillAngle; i++)
{
var rad = Mathf.Deg2Rad * (i * degrees);
var c = Mathf.Cos(rad);
var s = Mathf.Sin(rad);
var x = outer * c;
var y = inner * c;
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;
vh.AddUIVertexQuad(SetVBO(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
}
}
示例2: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper toFill)
{
if (this.font != null)
{
this.m_DisableFontTextureRebuiltCallback = true;
Vector2 size = base.rectTransform.rect.size;
TextGenerationSettings generationSettings = this.GetGenerationSettings(size);
this.cachedTextGenerator.PopulateWithErrors(this.text, generationSettings, base.gameObject);
IList<UIVertex> verts = this.cachedTextGenerator.verts;
float num = 1f / this.pixelsPerUnit;
int num2 = verts.Count - 4;
UIVertex vertex = verts[0];
UIVertex vertex2 = verts[0];
Vector2 point = (Vector2) (new Vector2(vertex.position.x, vertex2.position.y) * num);
point = base.PixelAdjustPoint(point) - point;
toFill.Clear();
if (point != 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 += point.x;
this.m_TempVerts[index].position.y += point.y;
if (index == 3)
{
toFill.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)
{
toFill.AddUIVertexQuad(this.m_TempVerts);
}
}
}
this.m_DisableFontTextureRebuiltCallback = false;
}
}
示例3: MakeQuad
/// <summary>
/// v0 v2
/// ┌─────┐ ↑
/// p0 quad p1 width
/// └─────┘ ↓
/// v1 v3
///
///
/// </summary>
/// <param name="prvVert"> v0, v1 </param>
/// <returns> {v0,v1,v2,v3}:UIVertex </returns>
UIVertex[] MakeQuad(VertexHelper vh, Vector3 p0, Vector3 p1, Color c0, Color c1, UIVertex[] prvVert=null)
{
Vector3 lineVector = p1 - p0;
Vector3 widthVector = Vector3.Cross(lineVector, new Vector3(0, 0, 1));
widthVector.Normalize();
UIVertex[] verts = new UIVertex[4];
if (prvVert != null)
{
verts[0] = prvVert[0];
verts[1] = prvVert[1];
}
else
{
verts[0].position = p0 + widthVector * width * 0.5f;
verts[1].position = p0 - widthVector * width * 0.5f;
}
verts[0].uv0 = new Vector2(0, 0);
verts[1].uv0 = new Vector2(1, 0);
verts[2].position = p1 - widthVector * width * 0.5f; verts[2].uv0 = new Vector2(1, 1);
verts[3].position = p1 + widthVector * width * 0.5f; verts[3].uv0 = new Vector2(0, 1);
verts[0].color = c0;
verts[1].color = c0;
verts[2].color = c1;
verts[3].color = c1;
vh.AddUIVertexQuad(verts);
return verts;
}
示例4: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper toFill)
{
if ((UnityEngine.Object) this.font == (UnityEngine.Object) null)
return;
this.m_DisableFontTextureRebuiltCallback = true;
this.cachedTextGenerator.Populate(this.text, this.GetGenerationSettings(this.rectTransform.rect.size));
Rect rect = this.rectTransform.rect;
Vector2 textAnchorPivot = Text.GetTextAnchorPivot(this.m_FontData.alignment);
Vector2 zero = Vector2.zero;
zero.x = Mathf.Lerp(rect.xMin, rect.xMax, textAnchorPivot.x);
zero.y = Mathf.Lerp(rect.yMin, rect.yMax, textAnchorPivot.y);
Vector2 vector2 = this.PixelAdjustPoint(zero) - zero;
IList<UIVertex> verts = this.cachedTextGenerator.verts;
float num1 = 1f / this.pixelsPerUnit;
int num2 = verts.Count - 4;
toFill.Clear();
if (vector2 != Vector2.zero)
{
for (int index1 = 0; index1 < num2; ++index1)
{
int index2 = index1 & 3;
this.m_TempVerts[index2] = verts[index1];
this.m_TempVerts[index2].position *= num1;
this.m_TempVerts[index2].position.x += vector2.x;
this.m_TempVerts[index2].position.y += vector2.y;
if (index2 == 3)
toFill.AddUIVertexQuad(this.m_TempVerts);
}
}
else
{
for (int index1 = 0; index1 < num2; ++index1)
{
int index2 = index1 & 3;
this.m_TempVerts[index2] = verts[index1];
this.m_TempVerts[index2].position *= num1;
if (index2 == 3)
toFill.AddUIVertexQuad(this.m_TempVerts);
}
}
this.m_DisableFontTextureRebuiltCallback = false;
}
示例5: 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);
}
}
示例6: OnPopulateMesh
/// <summary>
/// メッシュ生成(5.3以降版)
/// </summary>
/// <param name="vh"></param>
protected override void OnPopulateMesh( VertexHelper vh )
{
vh.Clear();
if ( vertices_ != null ) {
if ( oldColor_ != color ) {
int count = vertices_.Count;
for ( int i = 0; i < count; ++i ) {
var v = vertices_[i];
v.color = color;
vertices_[i] = v;
}
}
//UpdateVertices( false );
vh.AddUIVertexQuad( vertices_.ToArray() );
} else {
SetupVertices();
UpdateVertices( false );
vh.AddUIVertexQuad( vertices_.ToArray() );
}
}
示例7: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper 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 = Mathf.Lerp(inputRect.xMin, inputRect.xMax, textAnchorPivot.x);
refPoint.y = Mathf.Lerp(inputRect.yMin, inputRect.yMax, textAnchorPivot.y);
// 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;
toFill.Clear();
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)
toFill.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)
toFill.AddUIVertexQuad(m_TempVerts);
}
}
m_DisableFontTextureRebuiltCallback = false;
}
示例8: 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;
}
}
示例9: OnPopulateMesh
protected override void OnPopulateMesh(VertexHelper toFill)
{
if (fontSize == 0)
{
toFill.Clear();
return;
}
m_DisableDirty = true;
if (font != null)
{
m_DisableFontTextureRebuiltCallback = true;
cachedTextGenerator.Populate(IconDecoder.Decode(text), GetGenerationSettings(rectTransform.rect.size));
Rect rect = rectTransform.rect;
Vector2 textAnchorPivot = GetTextAnchorPivot(alignment);
Vector2 zero = Vector2.zero;
zero.x = textAnchorPivot.x != 1.0 ? rect.xMin : rect.xMax;
zero.y = textAnchorPivot.y != 0.0 ? rect.yMax : rect.yMin;
Vector2 vector2 = PixelAdjustPoint(zero) - zero;
IList<UIVertex> verts = cachedTextGenerator.verts;
float num1 = 1f / pixelsPerUnit;
int num2 = verts.Count - 4;
toFill.Clear();
if (vector2 != Vector2.zero)
{
for (int index1 = 0; index1 < num2; ++index1)
{
int index2 = index1 & 3;
m_TempVerts[index2] = verts[index1];
m_TempVerts[index2].position *= num1;
m_TempVerts[index2].position.x += vector2.x;
m_TempVerts[index2].position.y += vector2.y;
if (index2 == 3)
{
toFill.AddUIVertexQuad(m_TempVerts);
}
}
}
else
{
for (int index1 = 0; index1 < num2; ++index1)
{
int index2 = index1 & 3;
m_TempVerts[index2] = verts[index1];
m_TempVerts[index2].position *= num1;
if (index2 == 3)
{
toFill.AddUIVertexQuad(m_TempVerts);
}
}
}
m_DisableFontTextureRebuiltCallback = false;
}
m_DisableDirty = false;
}
示例10: Save
public void Save(VertexHelper vh)
{
vh.AddUIVertexQuad(V);
}