UnityEngine.UI.VertexHelper.SetUIVertex C# (CSharp) Method

SetUIVertex() public method

Set a UIVertex at the given index.

public SetUIVertex ( UIVertex vertex, int i ) : void
vertex UnityEngine.UIVertex
i int
return void
        public void SetUIVertex(UIVertex vertex, int i)
        {
            this.m_Positions[i] = vertex.position;
            this.m_Colors[i] = vertex.color;
            this.m_Uv0S[i] = vertex.uv0;
            this.m_Uv1S[i] = vertex.uv1;
            this.m_Normals[i] = vertex.normal;
            this.m_Tangents[i] = vertex.tangent;
        }

Usage Example

Example #1
1
    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);
         }
    }
All Usage Examples Of UnityEngine.UI.VertexHelper::SetUIVertex