U3D保存renderTexutre进文件
public class RTTSave : MonoBehaviour {private static int PIC_WIDTH = 256;
public RenderTexture RTTTex;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnClick()
{
if(RTTTex == null)
return ;
int width = RTTTex.width;
int height = RTTTex.height;
Texture2D tex2d = new Texture2D(width,height,TextureFormat.RGB24,false);
RenderTexture.active = RTTTex;
tex2d.ReadPixels(new Rect(0,0,width,height),0,0);
tex2d.Apply();
byte[] b = tex2d.EncodeToPNG();
//Destroy(tex2d);
File.WriteAllBytes(Application.dataPath + "1.jpg",b);
}
}
很不错 真心顶 难得一见的好帖 说的非常好 LZ真是人才 楼主是超人 好帖就是要顶 顶顶多好 真心顶