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); }
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); } }
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); }
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); }
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); } } }
public override void ModifyMesh(VertexHelper vertexHelper) { List<UIVertex> vertexList = new List<UIVertex>(); vertexHelper.GetUIVertexStream(vertexList); ModifyVertices(vertexList); vertexHelper.Clear(); vertexHelper.AddUIVertexTriangleStream(vertexList); }
public void ModifyMesh(VertexHelper helper) { var list = new List<UIVertex>(); helper.GetUIVertexStream(list); this.ModifyVertices(list); // calls the old ModifyVertices which was used on pre 5.2 helper.AddUIVertexTriangleStream(list); }
public override void ModifyMesh(VertexHelper vh) { if (this.IsActive()) { List<UIVertex> stream = ListPool<UIVertex>.Get(); vh.GetUIVertexStream(stream); this.ApplyShadow(stream, this.effectColor, 0, stream.Count, this.effectDistance.x, this.effectDistance.y); vh.Clear(); vh.AddUIVertexTriangleStream(stream); ListPool<UIVertex>.Release(stream); } }
public override void ModifyMesh(VertexHelper vertexHelper) { if (!this.IsActive()) return; List<UIVertex> list = new List<UIVertex>(); vertexHelper.GetUIVertexStream(list); ModifyVertices(list); vertexHelper.AddUIVertexTriangleStream(list); }
public override void ModifyMesh(VertexHelper vh) { List<UIVertex> list = new List<UIVertex>(); vh.GetUIVertexStream(list); vh.Clear(); for (int i = 0; i < list.Count; i++) { var v = list[i]; v.uv1 = AlphaUV[IndexMap[i]]; list[i] = v; } vh.AddUIVertexTriangleStream(list); }
// // ------------------------------------------------------------------>>>>>> TO HERE!! public override void ModifyMesh(VertexHelper vh) { if (!this.IsActive()) return; List<UIVertex> vertexList = new List<UIVertex>(); vh.GetUIVertexStream(vertexList); ModifyVertices(vertexList); vh.Clear(); vh.AddUIVertexTriangleStream(vertexList); }
public void ModifyMesh(VertexHelper vertexHelper) { if (!this.enabled) return; List<UIVertex> list = new List<UIVertex>(); vertexHelper.GetUIVertexStream(list); ModifyVertices(list); // calls the old ModifyVertices which was used on pre 5.2 vertexHelper.Clear(); vertexHelper.AddUIVertexTriangleStream(list); }
static public int AddUIVertexTriangleStream(IntPtr l) { try { UnityEngine.UI.VertexHelper self = (UnityEngine.UI.VertexHelper)checkSelf(l); System.Collections.Generic.List <UnityEngine.UIVertex> a1; checkType(l, 2, out a1); self.AddUIVertexTriangleStream(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public override void ModifyMesh (VertexHelper vh) { if (IsActive() == false) { return; } var vList = new List<UIVertex>(); vh.GetUIVertexStream(vList); ModifyVertices(vList); vh.Clear(); vh.AddUIVertexTriangleStream(vList); }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) { return; } var vertexList = new List<UIVertex>(); vh.GetUIVertexStream(vertexList); int count = vertexList.Count; ApplyGradient(vertexList, 0, count); vh.Clear(); vh.AddUIVertexTriangleStream(vertexList); }
public override void ModifyMesh(VertexHelper vh) #endif { if (!this.IsActive()) return; List<UIVertex> list = new List<UIVertex>(); vh.GetUIVertexStream(list); ModifyVertices(list); #if UNITY_5_2_1pX || UNITY_5_3 vh.Clear(); #endif vh.AddUIVertexTriangleStream(list); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper vh) { if (!IsActive()) { return; } List <UIVertex> vertices = new List <UIVertex>(); vh.GetUIVertexStream(vertices); TextMove(ref vertices); vh.Clear(); vh.AddUIVertexTriangleStream(vertices); }
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); } } }
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); } }
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); } }
public override void ModifyMesh(VertexHelper vh) { if (this.IsActive() == false) { return; } List<UIVertex> list = this.temp;//ListPool<UIVertex>.Get(); vh.GetUIVertexStream(list); this.ModifyVertices(list); vh.Clear(); vh.AddUIVertexTriangleStream(list); //ListPool<UIVertex>.Release(list); this.temp.Clear(); }
protected override void OnPopulateMesh(VertexHelper vh) { base.OnPopulateMesh(vh); List<UIVertex> stream = new List<UIVertex>(); vh.GetUIVertexStream(stream); for (int i = 0; i < stream.Count; i++) { UIVertex v = stream[i]; float percentCircumference = v.position.x/circumference; Vector3 offset = Quaternion.Euler(0.0f,0.0f,-percentCircumference*360.0f)*Vector3.up; v.position = offset*radius*scaleFactor + offset*v.position.y; v.position += Vector3.down*radius*scaleFactor; stream[i] = v; } vh.AddUIVertexTriangleStream(stream); }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) { return; } List<UIVertex> vertexList = new List<UIVertex>(); vh.GetUIVertexStream(vertexList); int count = vertexList.Count; float bottomY = vertexList[0].position.y; float topY = vertexList[0].position.y; for (int i = 1; i < count; i++) { float y = vertexList[i].position.y; if (y > topY) { topY = y; } else if (y < bottomY) { bottomY = y; } } float uiElementHeight = topY - bottomY; for (int i = 0; i < count; i++) { UIVertex uiVertex = vertexList[i]; uiVertex.color = Color32.Lerp(bottomColor, topColor, (uiVertex.position.y - bottomY) / uiElementHeight); vertexList[i] = uiVertex; } vh.Clear(); vh.AddUIVertexTriangleStream(vertexList); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper vh) { initImage(); vh.Clear(); Vector2 StartPoint = new Vector2(OriginXStart * width, OriginYStart * height); Vector2 EndPointX = new Vector2(CoordinateXEnd * width, OriginYStart * height); Vector2 EndPointY = new Vector2(OriginXStart * width, CoordinateYEnd * height); #region 数据曲线: int count = listPoint.Count; float minValue = float.MaxValue; float maxValue = float.MinValue; for (int i = 0; i < listPoint.Count; i++) { if (listPoint[i] > maxValue) { maxValue = listPoint[i]; } if (listPoint[i] < minValue) { minValue = listPoint[i]; } } xMin = 0; xMax = listPoint.Count; yMin = minValue; yMax = maxValue; float xoffset = (EndPointX.x - StartPoint.x) / count; float yoofset = ((YEndDraw - YStartDraw) * height) / (maxValue - minValue); List <Vector2> listTemp = new List <Vector2>(); for (int i = 0; i < listPoint.Count; i++) { float x = i * xoffset + StartPoint.x; float y = yoofset * (listPoint[i] - minValue) + YStartDraw * height; listTemp.Add(new Vector2(x, y)); } List <UIVertex> lis = EMeshTools.getTriangleStrame(listTemp, 2, Color.green , true); vh.AddUIVertexTriangleStream(lis); #endregion #region 画坐标轴 UIVertex[] lineX = GetQuaLine(StartPoint, EndPointX, 2, Color.gray); if (lineX != null && lineX.Length == 4) { vh.AddUIVertexQuad(lineX); } UIVertex[] lineY = GetQuaLine(StartPoint, EndPointY, 2, Color.gray); if (lineY != null && lineY.Length == 4) { vh.AddUIVertexQuad(lineY); } #endregion #region 绘制参考线 /* * Vector2 StartPoint_R1 = new Vector2 (XReferencePos_1 * width,OriginYStart*height); * Vector2 EndPoint_R1 = new Vector2 (XReferencePos_1 * width, CoordinateYEnd*height); * UIVertex[] line_X1 = GetQuaLine (StartPoint_R1, EndPoint_R1, 1,Color.red); * if (lineX != null && lineX.Length == 4) { * vh.AddUIVertexQuad (line_X1); * } */ #endregion }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) { return; } var verts = new List <UIVertex>(); vh.GetUIVertexStream(verts); var neededCpacity = verts.Count * 5; if (verts.Capacity < neededCpacity) { verts.Capacity = neededCpacity; } if (glintEffect) { for (int i = 0; i < verts.Count; i++) { UIVertex item = verts[i]; for (int j = -glintWidth; j <= glintWidth; j++) { if (i % 6 == Mathf.Repeat(glintVertex + j, 6)) { item.color = glintColor; } } verts[i] = item; } } Vector2 m_effectDistance = new Vector2(m_size, m_size); var start = 0; var end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, m_effectDistance.x, m_effectDistance.y); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, m_effectDistance.x, -m_effectDistance.y); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -m_effectDistance.x, m_effectDistance.y); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -m_effectDistance.x, -m_effectDistance.y); ////////////////////////////// start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, 0, m_effectDistance.y * 1.5f); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, m_effectDistance.x * 1.5f, 0); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -m_effectDistance.x * 1.5f, 0); start = end; end = verts.Count; ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, 0, -m_effectDistance.y * 1.5f); vh.Clear(); vh.AddUIVertexTriangleStream(verts); }
public override void ModifyMesh(VertexHelper vh) { if (!this.IsActive()) return; List<UIVertex> list = ListPool<UIVertex>.Get(); vh.GetUIVertexStream(list); this.ApplyShadow(list, (Color32) this.effectColor, 0, list.Count, this.effectDistance.x, this.effectDistance.y); vh.Clear(); vh.AddUIVertexTriangleStream(list); ListPool<UIVertex>.Release(list); }
//public Color32 topColor = Color.white; //public Color32 bottomColor = Color.black; //public override void ModifyMesh(VertexHelper helper) //{ // if (!this.IsActive() || helper.currentVertCount == 0) // return; // List<UIVertex> vertexs = new List<UIVertex>(); // helper.GetUIVertexStream(vertexs); // float bottomY = vertexs[0].position.y; // float topY = vertexs[0].position.y; // for (int i = 1; i < vertexs.Count; i++) // { // float y = vertexs[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); // } //} public override void ModifyMesh(VertexHelper vh) { if (!IsActive() || mGradient == null) { return; } List<UIVertex> vertexList = new List<UIVertex>(); vh.GetUIVertexStream(vertexList); if (vertexList == null || vertexList.Count == 0) { return; } float leftX = vertexList[0].position.x; float rightX = vertexList[0].position.x; float bottomY = vertexList[0].position.y; float topY = vertexList[0].position.y; for (int i = 1; i < vertexList.Count; i++) { float y = vertexList[i].position.y; if (y > topY) { topY = y; } else if (y < bottomY) { bottomY = y; } float x = vertexList[i].position.x; if (x > rightX) { rightX = x; } else if (x < leftX) { leftX = x; } } for (int i = 0; i < vertexList.Count; i++) { UIVertex uiVertex = vertexList[i]; if (mDirection == Direction.Vertical) { uiVertex.color = mGradient.Evaluate((uiVertex.position.y - bottomY) / (topY - bottomY)); } else { uiVertex.color = mGradient.Evaluate((uiVertex.position.x - leftX) / (rightX - leftX)); } vertexList[i] = uiVertex; } vh.Clear(); vh.AddUIVertexTriangleStream(vertexList); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper helper) { if (!IsActive()) { return; } List <UIVertex> verts = ListPool <UIVertex> .Get(); helper.GetUIVertexStream(verts); Text text = GetComponent <Text>(); if (text == null) { Debug.LogWarning("LetterSpacing: Missing Text component"); return; } Vector3 pos; float letterOffset = spacing * (float)text.fontSize / 100f; float alignmentFactor = 0; int glyphIdx = 0; switch (text.alignment) { case TextAnchor.LowerLeft: case TextAnchor.MiddleLeft: case TextAnchor.UpperLeft: alignmentFactor = 0f; break; case TextAnchor.LowerCenter: case TextAnchor.MiddleCenter: case TextAnchor.UpperCenter: alignmentFactor = 0.5f; break; case TextAnchor.LowerRight: case TextAnchor.MiddleRight: case TextAnchor.UpperRight: alignmentFactor = 1f; break; } //for (int lineIdx=0; lineIdx < lines.Length; lineIdx++) { string line = text.text; float lineOffset = (line.Length - 1) * letterOffset * alignmentFactor; for (int charIdx = 0; charIdx < line.Length; charIdx++) { int idx1 = glyphIdx * 6 + 0; int idx2 = glyphIdx * 6 + 1; int idx3 = glyphIdx * 6 + 2; int idx4 = glyphIdx * 6 + 3; int idx5 = glyphIdx * 6 + 4; int idx6 = glyphIdx * 6 + 5; // Check for truncated text (doesn't generate verts for all characters) if (idx4 > verts.Count - 1) { return; } UIVertex vert1 = verts[idx1]; UIVertex vert2 = verts[idx2]; UIVertex vert3 = verts[idx3]; UIVertex vert4 = verts[idx4]; UIVertex vert5 = verts[idx5]; UIVertex vert6 = verts[idx6]; pos = Vector3.right * (letterOffset * charIdx - lineOffset); vert1.position += pos; vert2.position += pos; vert3.position += pos; vert4.position += pos; vert5.position += pos; vert6.position += pos; verts[idx1] = vert1; verts[idx2] = vert2; verts[idx3] = vert3; verts[idx4] = vert4; verts[idx5] = vert5; verts[idx6] = vert6; glyphIdx++; } // Offset for carriage return character that still generates verts glyphIdx++; } helper.Clear(); helper.AddUIVertexTriangleStream(verts); verts.ReleaseToPool(); }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) return; var output = ListPool<UIVertex>.Get(); vh.GetUIVertexStream(output); ApplyShadow(output, effectColor, 0, output.Count, effectDistance.x, effectDistance.y); vh.Clear(); vh.AddUIVertexTriangleStream(output); ListPool<UIVertex>.Release(output); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper helper) { var verts = ListPool <UIVertex> .Get(); var newVerts = ListPool <UIVertex> .Get(); helper.GetUIVertexStream(verts); helper.Clear(); int count = verts.Count; int shapeCount = count / 6; int shapeIndex = 0; for (int i = 0; i < shapeCount; ++i) { int curIndex = i * 6; bool isUVVertical = (GetComponent <Graphic>() is Text) && (verts [curIndex].uv0.x == verts [curIndex + 1].uv0.x); Vector2 minUV = verts [curIndex + 0].uv0; Vector2 maxUV = verts [curIndex + 2].uv0; Vector3 minPos = verts [curIndex + 0].position; Vector3 maxPos = verts [curIndex + 2].position; Vector3 lengthPos = (maxPos - minPos) / m_Fineness; Vector2 lengthUV = (maxUV - minUV) / m_Fineness; for (int j = 0; j < m_Fineness; ++j) { for (int k = 0; k < 6; ++k) { var vert = verts [curIndex + k]; float x = 0; float y = 0; float uvx = 0; float uvy = 0; bool isX = (k == 0 || k == 4 || k == 5); bool isY = (k == 0 || k == 1 || k == 5); if ((isUVVertical && isX) || (!isUVVertical && isY)) { uvy = isUVVertical ? minUV.y + lengthUV.y * j : minUV.y; y = minPos.y; } else { uvy = isUVVertical ? minUV.y + lengthUV.y * (j + 1) : maxUV.y; y = maxPos.y; } y = (isY ? minPos.y : maxPos.y); if ((isUVVertical && isY) || (!isUVVertical && isX)) { uvx = isUVVertical ? minUV.x : minUV.x + lengthUV.x * j; } else { uvx = isUVVertical ? maxUV.x : minUV.x + lengthUV.x * (j + 1); } x = (isX ? minPos.x + lengthPos.x * j : minPos.x + lengthPos.x * (j + 1)); vert.position = new Vector3(x, y, minPos.z); vert.uv0 = new Vector2(uvx, uvy); newVerts.Add(vert); } } shapeIndex += m_Fineness; } helper.Clear(); helper.AddUIVertexTriangleStream(newVerts); newVerts.ReleaseToPool(); verts.ReleaseToPool(); }