2015年11月18日 星期三

Unity - Mirror/Flip Mesh

除了將scale x = -1外, 更好的方法如下:

using UnityEngine;

public class flipMesh : MonoBehaviour {

 // Use this for initialization
 void Start () {

        Mesh mesh = GetComponent().mesh;
        Vector2[] uv = mesh.uv;
        int szV = uv.Length;
        Vector2[] newUv = new Vector2[szV];
        for (int j = 0; j < szV; j++)
        {
            newUv[j] = new Vector2(uv[szV - j - 1].x, uv[j].y);
        }
        mesh.uv = newUv;

    }
}

沒有留言:

張貼留言