本文整理汇总了C#中UnityEngine.UI.VertexHelper类的典型用法代码示例。如果您正苦于以下问题:C# VertexHelper类的具体用法?C# VertexHelper怎么用?C# VertexHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexHelper类属于UnityEngine.UI命名空间,在下文中一共展示了VertexHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModifyMesh
public override void ModifyMesh(VertexHelper helper)
{
if (!IsActive() || helper.currentVertCount == 0)
return;
List<UIVertex> vertices = new List<UIVertex>();
helper.GetUIVertexStream(vertices);
float bottomY = vertices[0].position.y;
float topY = vertices[0].position.y;
for (int i = 1; i < vertices.Count; i++)
{
float y = vertices[i].position.y;
if (y > topY)
{
topY = y;
}
else if (y < bottomY)
{
bottomY = y;
}
}
float uiElementHeight = topY - bottomY;
UIVertex v = new UIVertex();
for (int i = 0; i < helper.currentVertCount; i++)
{
helper.PopulateUIVertex(ref v, i);
v.color = Color32.Lerp(bottomColor, topColor, (v.position.y - bottomY) / uiElementHeight);
helper.SetUIVertex(v, i);
}
}
示例2: ModifyMesh
public override void ModifyMesh(VertexHelper vh)
{
if (!this.IsActive())
return;
List<UIVertex> list = ListPool<UIVertex>.Get();
vh.GetUIVertexStream(list);
int num = list.Count * 5;
if (list.Capacity < num)
list.Capacity = num;
int start1 = 0;
int count1 = list.Count;
this.ApplyShadowZeroAlloc(list, (Color32) this.effectColor, start1, list.Count, this.effectDistance.x, this.effectDistance.y);
int start2 = count1;
int count2 = list.Count;
this.ApplyShadowZeroAlloc(list, (Color32) this.effectColor, start2, list.Count, this.effectDistance.x, -this.effectDistance.y);
int start3 = count2;
int count3 = list.Count;
this.ApplyShadowZeroAlloc(list, (Color32) this.effectColor, start3, list.Count, -this.effectDistance.x, this.effectDistance.y);
int start4 = count3;
int count4 = list.Count;
this.ApplyShadowZeroAlloc(list, (Color32) this.effectColor, start4, list.Count, -this.effectDistance.x, -this.effectDistance.y);
vh.Clear();
vh.AddUIVertexTriangleStream(list);
ListPool<UIVertex>.Release(list);
}
示例3: 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);
}
}
示例4: 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);
}
}
}
示例5: ModifyMesh
public override void ModifyMesh(VertexHelper vh)
{
if (!IsActive())
return;
var verts = ListPool<UIVertex>.Get();
vh.GetUIVertexStream(verts);
var neededCpacity = verts.Count * 5;
if (verts.Capacity < neededCpacity)
verts.Capacity = neededCpacity;
var start = 0;
var end = verts.Count;
ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, effectDistance.x, effectDistance.y);
start = end;
end = verts.Count;
ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, effectDistance.x, -effectDistance.y);
start = end;
end = verts.Count;
ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -effectDistance.x, effectDistance.y);
start = end;
end = verts.Count;
ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -effectDistance.x, -effectDistance.y);
vh.Clear();
vh.AddUIVertexTriangleStream(verts);
ListPool<UIVertex>.Release(verts);
}
示例6: 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);
}
}
}
示例7: 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);
}
}
示例8: ModifyMesh
public override void ModifyMesh(VertexHelper vh)
{
if (!IsActive())
{
return;
}
List<UIVertex> verts = new List<UIVertex>();
vh.GetUIVertexStream(verts);
if (verts == null || verts.Count == 0)
{
return;
}
int start;
int end = 0;
for (float i = 0; i <= Mathf.PI * 2; i += Mathf.PI / (float)mDivideAmoumt)
{
start = end;
end = verts.Count;
ApplyShadow(verts, effectColor, start, end, effectDistance.x * Mathf.Cos(i), effectDistance.y * Mathf.Sin(i));
}
vh.Clear();
vh.AddUIVertexTriangleStream(verts);
}
示例9: 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);
}
}
}
示例10: 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);
}
}
示例11: 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);
}
}
示例12: ModifyMesh
public override void ModifyMesh(VertexHelper vertexHelper)
{
List<UIVertex> vertexList = new List<UIVertex>();
vertexHelper.GetUIVertexStream(vertexList);
ModifyVertices(vertexList);
vertexHelper.Clear();
vertexHelper.AddUIVertexTriangleStream(vertexList);
}
示例13: ModifyMesh
public void ModifyMesh(Mesh mesh)
{
using (var vh = new VertexHelper(mesh))
{
EditMesh(vh);
vh.FillMesh(mesh);
}
}
示例14: ModifyMesh
public override void ModifyMesh(VertexHelper vh)
{
UIVertex vertex = new UIVertex();
for (int i = 0; i < vh.currentVertCount; i++)
{
vh.PopulateUIVertex(ref vertex, i);
vertex.uv1 = new Vector2(vertex.position.x, vertex.position.y);
vh.SetUIVertex(vertex, i);
}
}
示例15: AddQuad
private static void AddQuad(VertexHelper vh, Vector3[] quadPositions, Color32 color, Vector3[] quadUVs)
{
int currentVertCount = vh.currentVertCount;
for (int i = 0; i < 4; i++)
{
vh.AddVert(quadPositions[i], color, quadUVs[i]);
}
vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
vh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount);
}