protected override void OnPopulateMesh(VertexHelper vh) { if (font == null) { return; } if (context != null) { vh.Clear(); if (vertex != null) { vh.AddUIVertexStream(vertex, new List <int>(tri)); } } else { var trans = Collector; if (trans == null) { trans = transform; } var vert = new List <UIVertex>(); for (int i = 0; i < trans.childCount; i++) { GetUVInfo(trans.GetChild(i) as RectTransform, this, vert, Vector3.zero, Quaternion.identity, Vector3.one); } var tri = CreateTri(vert.Count); vh.Clear(); vh.AddUIVertexStream(vert, new List <int>(tri)); } }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); if (isInitialState) { Array.Resize(ref pointsReal, points.Count); for (int i = 0; i < pointsReal.Length; ++i) { pointsReal[i] = new Vector2(points[i].x * rectTransform.rect.width, points[i].y * rectTransform.rect.height); } } var triangulator = new Triangulator(pointsReal); List <UIVertex> verts = new List <UIVertex> (); List <int> indices = new List <int> (); foreach (var point in pointsReal) { var vert = UIVertex.simpleVert; vert.color = color; vert.position = point; verts.Add(vert); } indices.AddRange(triangulator.Triangulate()); vh.AddUIVertexStream(verts, indices); }
public static void DrawLine(this VertexHelper vh, List <Vector2> positions, float width, Color color) { vh.Clear(); var list = new List <UIVertex>(); for (var i = 0; i < positions.Count; i++) { var point = positions[i]; var pointPrev = positions[i > 0 ? i - 1 : i]; var pointNext = positions[i < positions.Count - 1 ? i + 1 : i]; var uvy = i % 2 == 0 ? 1 : 0; var uv = new Vector2(uvy, 0); list.Add(Vertex(point, uv, color)); var diff = (pointNext - pointPrev).normalized; var normal = new Vector2(-diff.y, diff.x) * width; var uv2 = new Vector2(uvy, 1); list.Add(Vertex(point + normal, uv2, color)); } vh.AddUIVertexStream(list, ShapeTopology.TringleStrip((positions.Count - 1) * 2).ToList()); }
public static void DrawCone(this VertexHelper vh, Vector2 position, Vector2 radius, float width, float from, float to, int steps, Color color) { vh.Clear(); var list = new List <UIVertex>(); var step = (to - from) / steps; var radiusB = new Vector2(radius.x - width, radius.y - width); for (var i = 0; i < steps + 1; i++) { var a = from + i * step; var cos = Mathf.Cos(a); var sin = Mathf.Sin(a); var p = new Vector2(cos * radius.x, sin * radius.y) + position; var uv = new Vector2(cos, sin) * 0.5f + Vector2.one * 0.5f; list.Add(Vertex(p, uv, color)); var p2 = new Vector2(cos * radiusB.x, sin * radiusB.y) + position; var uvr = Vector2.one - new Vector2(width / radius.x, width / radius.y); var uv2 = new Vector2(cos * uvr.x, sin * uvr.y) * 0.5f + Vector2.one * 0.5f; list.Add(Vertex(p2, uv2, color)); } vh.AddUIVertexStream(list, ShapeTopology.TringleStrip(steps * 2).ToList()); }
public static void DrawArc(this VertexHelper vh, Vector2 position, Vector2 radius, float from, float to, int steps, Color color) { vh.Clear(); var list = new List <UIVertex>(); var step = (to - from) / steps; list.Add(Vertex(position, new Vector2(0.5f, 0.5f), color)); for (var i = 0; i < steps + 1; i++) { var a = from + i * step; var cos = Mathf.Cos(a); var sin = Mathf.Sin(a); var x = cos * radius.x + position.x; var y = sin * radius.y + position.y; var uv = new Vector2(cos, sin) * 0.5f + Vector2.one * 0.5f; list.Add(Vertex(new Vector2(x, y), uv, color)); } vh.AddUIVertexStream(list, ShapeTopology.TringleFan(steps).ToList()); }
public void DrawArc(VertexHelper vh, Vector2 position, Vector2 radius, float from, float to, int steps, Color color) { vh.Clear(); var list = new List <UIVertex>(); var step = (to - from) / steps; list.Add(Vertex(position, new Vector2(0.5f, 0.5f), color)); for (var i = 0; i < steps + 1; i++) { var a = from + i * step; var cos = Mathf.Cos(a); var sin = Mathf.Sin(a); var dirX = cos > 0 ? 1 : -1; var dirY = sin > 0 ? 1 : -1; var rx = Mathf.Pow(Mathf.Abs(cos), K) * dirX; var ry = Mathf.Pow(Mathf.Abs(sin), K) * dirY; var x = rx * radius.x + position.x; var y = ry * radius.y + position.y; var uv = new Vector2(0.5f + x / rectTransform.rect.width, 0.5f + y / rectTransform.rect.height); list.Add(Vertex(new Vector2(x, y), uv, color)); } vh.AddUIVertexStream(list, ShapeTopology.TringleFan(steps).ToList()); }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) { return; } if (!softMaskRect.orientedRect2D.Overlaps(orientedRect2D)) { vh.Clear(); return; } var vertices = new List <UIVertex>(); vh.GetUIVertexStream(vertices); vh.Clear(); var indices = Enumerable.Range(0, vertices.Count).ToList(); for (int i = 0, iMax = vertices.Count; i < iMax; ++i) { vertices[i] = SetPosition(vertices[i], rectTransform.TransformPoint(vertices[i].position)); } VertexUtility.Intersect(vertices, indices, softMaskRect.Vertices); for (int i = 0, iMax = vertices.Count; i < iMax; ++i) { vertices[i] = SetPosition(vertices[i], rectTransform.InverseTransformPoint(vertices[i].position)); } vh.AddUIVertexStream(vertices, indices); }
void Reset() { Size = new float[2]; Size[0] = 1f; Size[1] = 1f; loopTimer = 0f; colors = new Color[2]; colors[0] = Color.white; colors[1] = Color.white; gradient = new Gradient(); gradient2 = new Gradient(); PoolSize = 100; base.SetVerticesDirty(); vh = new VertexHelper(); particlePool.Clear(); vecs = new List <UIVertex>(new UIVertex[PoolSize * 4]); tri = new List <int>(new int[PoolSize * 6]); particlePool.Clear(); for (int i = 0; i < PoolSize; i++) { particlePool.Add(new UIParticle()); UIVertex[] vertices = new UIVertex[4]; } vh.AddUIVertexStream(new List <UIVertex>(vecs), new List <int>(tri)); }
protected override void OnPopulateMesh(VertexHelper vh) { if (canvas == null) { base.OnPopulateMesh(vh); return; } if (_gradientType == GradientType.Horizontal) { _xSize = _quadCount; _ySize = 1; } else { _xSize = 1; _ySize = _quadCount; } vh.Clear(); CalculateVertexes(); CalculateIndices(); vh.AddUIVertexStream(new List <UIVertex>(_vertexes), new List <int>(_indices)); }
protected override void OnPopulateMesh(VertexHelper vertex) { if (font == null) { return; } m_DisableFontTextureRebuiltCallback = true; vertex.Clear(); if (m_Text != emojiString.FullString) { emojiString.FullString = m_Text; } var vert = CreateEmojiMesh(this, emojiString); if (vert != null) { var v = new List <UIVertex>(vert); var tri = CreateTri(vert.Length); vertex.AddUIVertexStream(v, new List <int>(tri)); if (OnPopulate != null) { OnPopulate(this, vertex); } } m_DisableFontTextureRebuiltCallback = false; var tg = cachedTextGenerator; }
public override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); if (particleSystem == null) { return; } if (usesOptimizedShader) { shim.material.SetVector("_ScaleInfo", new Vector4(rectForThread.width / shapeSizeXForThread, rectForThread.height / shapeSizeYForThread, 0, 0)); } vh.AddUIVertexStream(particlesFromThread, particleIndicesFromThread); if (limitToInside) { // run through all of the particlesFromThread, if the first vertex tangent x is not zero, this particle should be removed. ParticleSystem.Particle[] removeParticles = new ParticleSystem.Particle[particleSystem.particleCount]; particleSystem.GetParticles(removeParticles); int lastIdx = removeParticles.Length; for (int i = removeParticles.Length - 1; i >= 0; i--) { if (particlesFromThread.Count > (i << 2) && particlesFromThread [i << 2].tangent.x == 99) { lastIdx--; removeParticles [i] = removeParticles [lastIdx]; } } particleSystem.SetParticles(removeParticles, lastIdx); } particleArrayThreadCommState = 0; }
public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } if (rectTransform == null) { rectTransform = GetComponent <RectTransform>(); } if (image == null) { image = GetComponent <Image>(); } if (image.type != Image.Type.Simple) { return; } Sprite sprite = image.overrideSprite; if (sprite == null || sprite.triangles.Length == 6) { return; } if (vh.currentVertCount != 4) { return; } rectTransform.GetLocalCorners(fourCorners); int len = sprite.vertices.Length; var vertices = new List <UIVertex>(len); Vector2 Center = sprite.bounds.center; Vector2 invExtend = new Vector2(1 / sprite.bounds.size.x, 1 / sprite.bounds.size.y); for (int i = 0; i < len; i++) { float x = (sprite.vertices[i].x - Center.x) * invExtend.x + 0.5f; float y = (sprite.vertices[i].y - Center.y) * invExtend.y + 0.5f; vertice.position = new Vector2(Mathf.Lerp(fourCorners[0].x, fourCorners[2].x, x), Mathf.Lerp(fourCorners[0].y, fourCorners[2].y, y)); vertice.color = image.color; vertice.uv0 = sprite.uv[i]; vertices.Add(vertice); } len = sprite.triangles.Length; var triangles = new List <int>(len); for (int i = 0; i < len; i++) { triangles.Add(sprite.triangles[i]); } vh.Clear(); vh.AddUIVertexStream(vertices, triangles); }
/// <summary> /// Update all renderer data. /// </summary> // OnFillVBO deprecated by 5.2 // OnPopulateMesh(Mesh mesh) deprecated by 5.2 patch 1 #if UNITY_5_4_OR_NEWER || (UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2_0) /* protected override void OnPopulateMesh(Mesh mesh) * { * List<UIVertex> verts = new List<UIVertex>(); * _OnFillVBO( verts ); * * var quad = new UIVertex[4]; * for (int i = 0; i < vbo.Count; i += 4) * { * vbo.CopyTo(i, quad, 0, 4); * vh.AddUIVertexQuad(quad); * } * vh.FillMesh( toFill ); * }*/ #if !UNITY_5_2_1 protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); _OnFillVBO(_vertices); vh.AddUIVertexStream(_vertices, QuadIndices); }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); if (isActiveAndEnabled && AnimationCurve != null) { vh.AddUIVertexStream(uiVertices, indexs); } }
/// <summary> /// Fill the vertex buffer data. /// </summary> /// <param name="_vh">顶点Helper</param> protected override void OnPopulateMesh(VertexHelper _vh) { _vh.Clear(); Vector4 originPos = sprite != null?this.GraphicDrawingDimensionsForVertexHelper(sprite, false) : Vector4.zero; Vector3 startRay = Vector3.up; float angle = 360f / edgeNum; if (edgeNum % 2 == 0) {//如果边数是偶数,则起始射线为向左偏移半个平均角度 startRay = Quaternion.AngleAxis(-angle * 0.5f, Vector3.up) * startRay; } Vector3[] vertexs = new Vector3[edgeNum + 1]; vertexs[0] = new Vector3(originPos.x + originPos.z, originPos.y + originPos.w, 0) * 0.5f; List <UIVertex> uiVertexs = new List <UIVertex>(); List <int> indices = new List <int>(); UIVertex vtx; uiVertexs.Add(new UIVertex() { position = vertexs[0], color = color, uv0 = Vector2.one * 0.5f }); Vector3 vec3 = Vector3.zero; Vector2 vecUv0 = Vector2.zero; float ratio = 0; for (int i = 0; i < edgeNum; i++) { vec3 = Quaternion.AngleAxis(angle * i, Vector3.back) * startRay; ratio = 0; if (edgeRatios != null && edgeRatios.Length > i) { ratio = Mathf.Clamp01(edgeRatios[i]); } vertexs[i + 1] = vec3 * radius * ratio + vertexs[0]; vecUv0 = vec3 + Vector3.one * 0.5f; vtx = new UIVertex() { position = vertexs[i + 1], color = color, uv0 = vecUv0 }; uiVertexs.Add(vtx); indices.Add(0); if (i >= edgeNum - 1) { indices.Add(i + 1); indices.Add(1); } else { indices.Add(i + 1); indices.Add(i + 2); } //Debug.Log(" uv:" + vtx.uv0 + " pos:" + vertexs[i + 1]); } _vh.AddUIVertexStream(uiVertexs, indices); }
protected override void OnPopulateMesh(VertexHelper vh) { if (!IsActive() || verts == null || verts.Count < 3) { base.OnPopulateMesh(vh); return; } vh.Clear(); vh.AddUIVertexStream(verts, indices); }
void GenerateCorner(Rect rect, VertexHelper vh) { vertexStream.Clear(); indexStream.Clear(); vh.Clear(); float cornerSize = Mathf.Max(width, cornerRadius); float cornerOffset = cornerSize; { Vector3 begin = new Vector2(rect.xMin, rect.yMin) + new Vector2(0, cornerOffset); Vector3 end = new Vector3(rect.xMin, rect.yMax) - new Vector3(0, cornerOffset); BeginLine(vertexStream, indexStream, begin, end); AddLine(vertexStream, indexStream, begin, end); Vector3 cornerBegin = end; Vector3 cornerEnd = new Vector3(rect.xMin, rect.yMax) + new Vector3(cornerOffset, 0); AddTopLeftCorner(vertexStream, indexStream, cornerBegin, cornerEnd); } { Vector3 begin = new Vector3(rect.xMin, rect.yMax) + new Vector3(cornerOffset, 0); Vector3 end = new Vector3(rect.xMax, rect.yMax) - new Vector3(cornerOffset, 0); AddLine(vertexStream, indexStream, begin, end); Vector3 cornerBegin = end; Vector3 cornerEnd = new Vector3(rect.xMax, rect.yMax) - new Vector3(0, cornerOffset, 0); AddTopRightCorner(vertexStream, indexStream, cornerBegin, cornerEnd); } { Vector3 begin = new Vector3(rect.xMax, rect.yMax) - new Vector3(0, cornerOffset, 0); Vector3 end = new Vector3(rect.xMax, rect.yMin) + new Vector3(0, cornerOffset, 0); AddLine(vertexStream, indexStream, begin, end); Vector3 cornerBegin = end; Vector3 cornerEnd = new Vector3(rect.xMax, rect.yMin) - new Vector3(cornerOffset, 0); AddBottomRightCorner(vertexStream, indexStream, cornerBegin, cornerEnd); } { Vector3 begin = new Vector3(rect.xMax, rect.yMin) - new Vector3(cornerOffset, 0); Vector3 end = new Vector3(rect.xMin, rect.yMin) + new Vector3(cornerOffset, 0); AddLine(vertexStream, indexStream, begin, end); Vector3 cornerBegin = end; Vector3 cornerEnd = new Vector2(rect.xMin, rect.yMin) + new Vector2(0, cornerOffset); AddBottomLeftCorner(vertexStream, indexStream, cornerBegin, cornerEnd); } EndLine(); PopulateUV(vertexStream); vh.AddUIVertexStream(vertexStream, indexStream); }
/// <summary> /// Update all renderer data. /// </summary> // OnFillVBO deprecated by 5.2 // OnPopulateMesh(Mesh mesh) deprecated by 5.2 patch 1 #if (UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2_0) || UNITY_5_4_OR_NEWER /* protected override void OnPopulateMesh(Mesh mesh) * { * List<UIVertex> verts = new List<UIVertex>(); * _OnFillVBO( verts ); * * var quad = new UIVertex[4]; * for (int i = 0; i < vbo.Count; i += 4) * { * vbo.CopyTo(i, quad, 0, 4); * vh.AddUIVertexQuad(quad); * } * vh.FillMesh( toFill ); * }*/ #if !UNITY_5_2_1 protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); List <UIVertex> aVerts = new List <UIVertex>(); _OnFillVBO(aVerts); List <int> aIndicies = new List <int>(new int[] { 0, 1, 2, 2, 3, 0 }); vh.AddUIVertexStream(aVerts, aIndicies); }
protected override void OnPopulateMesh(VertexHelper vh) { if (uIVertices.Count == 0) { base.OnPopulateMesh(vh); } else { vh.Clear(); vh.AddUIVertexStream(uIVertices, triangle); } }
/// <summary> /// Update all renderer data. /// </summary> // OnFillVBO deprecated by 5.2 // OnPopulateMesh(Mesh mesh) deprecated by 5.2 patch 1 #if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2_0 /* protected override void OnPopulateMesh(Mesh mesh) * { * List<UIVertex> verts = new List<UIVertex>(); * _OnFillVBO( verts ); * * var quad = new UIVertex[4]; * for (int i = 0; i < vbo.Count; i += 4) * { * vbo.CopyTo(i, quad, 0, 4); * vh.AddUIVertexQuad(quad); * } * vh.FillMesh( toFill ); * }*/ #if !UNITY_5_2_1 protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); List <UIVertex> aVerts = new List <UIVertex>(); _OnFillVBO(aVerts); // TODO: cache these indices since they never change? List <int> aIndicies = new List <int>(new int[] { 0, 1, 2, 2, 3, 0 }); vh.AddUIVertexStream(aVerts, aIndicies); }
public void Draw(VertexHelper vh, Vector2 center, Vector2 size) { vh.Clear(); list.Clear(); AddArc(new Vector2(size.x - RadiusUpRight, size.y - RadiusUpRight), RadiusUpRight, 0); AddArc(new Vector2(-size.x + RadiusUpLeft, size.y - RadiusUpLeft), RadiusUpLeft, Mathf.PI * 0.5f); AddArc(new Vector2(-size.x + RadiusBottomLeft, -size.y + RadiusBottomLeft), RadiusBottomLeft, Mathf.PI); AddArc(new Vector2(size.x - RadiusBottomRight, -size.y + RadiusBottomRight), RadiusBottomRight, Mathf.PI * 1.5f); AddVertex(new Vector2(size.x, size.y - RadiusUpRight)); AddVertex(new Vector2(size.x - Width, size.y - RadiusUpRight)); vh.AddUIVertexStream(list, ShapeTopology.TringleStrip((Steps + 1) * 8).ToList()); }
private void addVertices(VertexHelper vh) { List <UIVertex> list = new List <UIVertex>(); vh.GetUIVertexStream(list); UIVertex bottomLeft = list[0]; UIVertex topLeft = list[1]; UIVertex topRight = list[2]; UIVertex bottomRight = list[4]; List <UIVertex> verticesForRect = getVerticesForRect(NumVertices, bottomLeft, topLeft, topRight, bottomRight); List <int> indicesForRect = getIndicesForRect(NumVertices); vh.Clear(); vh.AddUIVertexStream(verticesForRect, indicesForRect); }
public override void ModifyMesh(VertexHelper p_vertexHelper) { if (!IsActive()) { return; } RecalcMesh(); List <UIVertex> v_vertexList = new List <UIVertex>(); List <int> v_triangles = new List <int>(); if (DrawMeshGraphics && _mesh != null) { var v_vertices = _mesh.vertices; var v_tringles = _mesh.triangles; var v_normals = _mesh.normals; var v_colors = _mesh.colors32; var v_uvs = _mesh.uv; v_triangles.AddRange(_mesh.triangles); for (int i = 0; i < v_vertices.Length; i++) { UIVertex v_vertex = new UIVertex(); v_vertex.position = v_vertices[i]; if (v_normals.Length > i) { v_vertex.normal = v_normals[i]; } else { v_vertex.normal = Vector3.one; } if (v_colors.Length > i) { v_vertex.color = v_colors[i]; } if (v_uvs.Length > i) { v_vertex.uv0 = v_uvs[i]; } v_vertexList.Add(v_vertex); } } ApplyWireframe(v_vertexList, v_triangles); p_vertexHelper.Clear(); p_vertexHelper.AddUIVertexStream(v_vertexList, v_triangles); }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); if (m_Graphics != null && m_Graphics.Count > 0) { foreach (var item in m_Graphics) { int offset = m_Vertexs.Count; item.GetVertexs(ref m_Vertexs); item.GetTriangles(ref m_Triangles, offset); } } vh.AddUIVertexStream(m_Vertexs, m_Triangles); m_Vertexs?.Clear(); m_Triangles?.Clear(); }
protected override void OnPopulateMesh(VertexHelper p_toFill) { if (Mesh == null) { base.OnPopulateMesh(p_toFill); } else { p_toFill.Clear(); var v_vertices = Mesh.vertices; var v_triangles = Mesh.triangles; var v_uvs = Mesh.uv; var v_colors = Mesh.colors32; var v_normals = _mesh.normals; List <UIVertex> v_vertexTriangles = new List <UIVertex>(); for (int i = 0; i < v_triangles.Length; i++) { UIVertex v_vertex = new UIVertex(); if (v_vertices.Length > i) { v_vertex.position = v_vertices[i]; } if (v_colors.Length > i) { v_vertex.color = v_colors[i]; } if (v_uvs.Length > i) { v_vertex.uv0 = v_uvs[i]; v_vertex.uv1 = v_uvs[i]; } if (v_normals.Length > i) { v_vertex.normal = v_normals[i]; } else { v_vertex.normal = Vector3.one; } v_vertexTriangles.Add(v_vertex); } p_toFill.AddUIVertexStream(v_vertexTriangles, new List <int>(v_triangles)); } }
protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear(); List <UIVertex> list = new List <UIVertex>(); _OnFillVBO(list); List <int> indicies = new List <int>(new int[6] { 0, 1, 2, 2, 3, 0 }); vh.AddUIVertexStream(list, indicies); }
void FillVertexHelper(VertexHelper vh, Mesh mesh) { vh.Clear(); mesh.GetVertices(s_Vertices); mesh.GetColors(s_Colors); mesh.GetUVs(0, s_Uv0); mesh.GetUVs(1, s_Uv1); mesh.GetNormals(s_Normals); mesh.GetTangents(s_Tangents); mesh.GetIndices(s_Indices, 0); #if UNITY_2017_1_OR_NEWER mesh.GetUVs(2, s_Uv2); mesh.GetUVs(3, s_Uv3); bool useUv2 = 0 < s_Uv2.Count; bool useUv3 = 0 < s_Uv3.Count; #endif s_UIVertices.Clear(); UIVertex v = default(UIVertex); for (int i = 0; i < s_Vertices.Count; i++) { v.position = s_Vertices[i]; v.color = s_Colors[i]; v.uv0 = s_Uv0[i]; v.uv1 = s_Uv1[i]; #if UNITY_2017_1_OR_NEWER if (useUv2 && i < s_Uv2.Count) { v.uv2 = s_Uv2[i]; } if (useUv3 && i < s_Uv3.Count) { v.uv3 = s_Uv3[i]; } #endif v.normal = s_Normals[i]; v.tangent = s_Tangents[i]; s_UIVertices.Add(v); } s_VertexHelper.AddUIVertexStream(s_UIVertices, s_Indices); }
protected override void OnPopulateMesh(VertexHelper vh) { var rect = GetPixelAdjustedRect(); float xmin = rect.xMin + margin.left; float xmax = rect.xMax - margin.right; float ymin = rect.yMin + margin.bottom; float ymax = rect.yMax - margin.top; float w = (xmax - xmin); float h = (ymax - ymin); Vector2[] verts = { new Vector2(xmin, ymin), new Vector2(xmin, ymax), new Vector2(xmax, ymax), new Vector2(xmax, ymin) }; vh.Clear(); UIVertex uiv = UIVertex.simpleVert; var uiverts = new List <UIVertex>(4); foreach (var v in verts) { uiv.position = new Vector2(v.x, v.y); uiv.uv0 = new Vector2((v.x - xmin) / w, (v.y - ymin) / h); uiv.uv1 = new Vector2(w, h); uiv.uv2 = new Vector2(overrideCornerRadius, overrideBorderWidth); uiv.color = color; // vh.AddVert(uiv); // This method is not assign uv2 in 2018.3.6f1. uiverts.Add(uiv); } // vh.AddTriangle(0, 1, 2); // vh.AddTriangle(2, 3, 0); var triinds = new List <int>(new int[] { 0, 1, 2, 2, 3, 0 }); vh.AddUIVertexStream(uiverts, triinds); }
protected override void OnPopulateMesh(VertexHelper vh) { if (sourceMedia == null) { return; } // Get the indices List <int> indices = new List <int>(new int[] { 0, 1, 2, 2, 3, 0 }); // Get the vertices List <UIVertex> vertices = new List <UIVertex>(); FillVerticesList(vertices); // Feed the data to VertexHelper vh.Clear(); vh.AddUIVertexStream(vertices, indices); }
public override void ModifyMesh(VertexHelper vh) { if (mEdgeSizeList.Count == 0) { return; } mVerts.Clear(); mIndices.Clear(); UIVertex startVertex = new UIVertex(); startVertex.position = Vector3.zero; //startVertex.color = mColor; mVerts.Add(startVertex); for (int i = 0; i < mEdgeMaxNum; i++) { UIVertex vertex = new UIVertex(); vertex.position = GetVertexPos(i); vertex.color = mColor; mVerts.Add(vertex); } for (int i = 0; i < mEdgeMaxNum;) { mIndices.Add(0); mIndices.Add(i + 1); if (i + 2 == mEdgeMaxNum + 1) { mIndices.Add((i + 2) % mEdgeMaxNum); } else { mIndices.Add(i + 2); } i = i + 1; } vh.Clear(); vh.AddUIVertexStream(mVerts, mIndices); }