How to manipulate vertices of the Rect Transform ?

Hi everyone,

So i was wondering if it is possible to manipulate vertices of Rect Transform, by code, to go from picture A to B or C. Or if it’s possible in another way to deform an image?

65336-example-vertice-rect-transform.png

Thank you very much in advance.

You can manipulate vertices of a UI component by using inheritance and override OnPopulateMesh

public class ReshapeImage : Image 
{
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        base.OnPopulateMesh(vh);

        for (int i = 0; i < vh.currentVertCount; i++)
        {
            UIVertex vert = UIVertex.simpleVert;
            vh.PopulateUIVertex(ref vert, i);
            Vector3 position = vert.position;

            //
            //manipulate position
            //

            vert.position = position;
            vh.SetUIVertex(vert, i);
        }
    }
}