//水平翻转图片
public static Texture2D horizontalFlipPic(Texture2D texture2d)
{
int width = texture2d.width;
int height = texture2d.height;
Texture2D texture = new Texture2D(width, height);
for (int i = 0; i < width; i++)
{
texture.SetPixels(i, 0, 1, height, texture2d.GetPixels(width - i - 1, 0, 1, height));
}
texture.Apply();
return texture;
}
//垂直翻转图片
public static Texture2D verticalFlipPic(Texture2D texture2d)
{
int width = texture2d.width;
int height = texture2d.height;
Texture2D texture = new Texture2D(width, height);
for (int i = 0; i < height; i++)
{
texture.SetPixels(0, i, width, 1, texture2d.GetPixels(0, width - i - 1, width, 1));
}
texture.Apply();
return texture;
}
水平和垂直翻转图片
最新推荐文章于 2022-12-28 14:54:20 发布