项目分享:https://github.com/Claymoreno1/RenderTexture
这一次添加了水平翻转、垂直翻转、顺时针旋转、逆时针旋转,关闭图像,保存,退出功能;对RT的创建和销毁做了一些更改。
界面如下:
关于选择的C#部分
public void clockwise()
{
clockw = true;
rotate();
}
public void anticlockwise()
{
anclockw = true;
rotate();
}
private void rotate()//旋转shader更新
{
if (Gamevars.textureisable)
{
rotatematerial.SetInt("_Clockwise", clockw ? 1 : 0);
rotatematerial.SetInt("_AnuiClockwise", anclockw? 1:0);
RenderTexture Disttexture =RenderTexture.GetTemporary(texture.height, texture.width, 0);//因为旋转之后宽高对调
Graphics.Blit(texture, Disttexture, rotatematerial);
int width = Disttexture.width;
int height = Disttexture.height;
Gamevars.imagewidth = width;
Gamevars.imageheight = height;//更新控制结构体
Viewtexture = new Texture2D(width, height, TextureFormat.ARGB32, false);
RenderTexture