Aspect为屏幕的分辨率width/height;
orthographicSize为高度height的一半,大小影像屏幕内物体大小,可视范围;
viewport rect 中H<=1,W任意,但要保证范围大于screen的区间;
利用正交相机制作小地图,rendertexture的height=orthographicsize*2;width=orthographicsize*2*_radio(手动设置);
//将RenderTexture保存成一张png图片
public bool SaveRenderTextureToPNG(RenderTexture rt, string contents, string pngName)
{
RenderTexture prev = RenderTexture.active;
RenderTexture.active = rt;
Texture2D png = new Texture2D(rt.width, rt.height, TextureFormat.ARGB32, false);
png.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
byte[] bytes = png.EncodeToPNG();
if (!Directory.Exists(contents))
Directory.CreateDirectory(contents);
FileStream file = File.Open(contents + "/" + pngName + ".png", FileMode.Create);
BinaryWriter writer = new BinaryWriter(file);
writer.Write(bytes);
file.Close();
Texture2D.DestroyImmediate(png);
png = null;
RenderTexture.active = prev;
return true;
}