unity 中实现图片折叠 伪3D 的效果

using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Image))]
public class VariantImage : BaseMeshEffect
{
    public Vector2[] offset=new Vector2[4];
    public override void ModifyMesh(VertexHelper vh)
    {
        List stream=new List();
        vh.GetUIVertexStream(stream);
        UIVertex vertex = new UIVertex();
        for (int i = 0; i < vh.currentVertCount && i < offset.Length;i++)
        {
            vh.PopulateUIVertex(ref  vertex, i);
            vertex.position = vertex.position + new Vector3(offset[i].x,offset[i].y,0);
            vh.SetUIVertex(vertex, i);
        }
    }
}
 

你可能感兴趣的:(unity)