/// <summary>
/// 截屏方法
/// </summary>
/// <param name="c">指定摄像机截屏</param>
/// <param name="t">截屏范围</param>
void CaptureScreenMethod3(Camera c, Rect t)
{
RenderTexture rt = new RenderTexture((int)t.width, (int)t.height, 0);
c.targetTexture = rt;
c.Render();
RenderTexture.active = rt;
Texture2D screenShot = new Texture2D((int)t.width, (int)t.height, TextureFormat.RGB24, false);
screenShot.ReadPixels(t, 0, 0);
screenShot.Apply();
//GameObject.Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
string fileName = Application.dataPath + "/liu2.png";
System.IO.File.WriteAllBytes(fileName, bytes);
}
/// 截屏方法
/// </summary>
/// <param name="c">指定摄像机截屏</param>
/// <param name="t">截屏范围</param>
void CaptureScreenMethod3(Camera c, Rect t)
{
RenderTexture rt = new RenderTexture((int)t.width, (int)t.height, 0);
c.targetTexture = rt;
c.Render();
RenderTexture.active = rt;
Texture2D screenShot = new Texture2D((int)t.width, (int)t.height, TextureFormat.RGB24, false);
screenShot.ReadPixels(t, 0, 0);
screenShot.Apply();
//GameObject.Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
string fileName = Application.dataPath + "/liu2.png";
System.IO.File.WriteAllBytes(fileName, bytes);
}