获取camera截屏图片

Camera camera;

SpriteRenderer sprRender;

Texture2D t2d = New Texture2D(1300, 760, TextureFormat.RGB24, false)

RenderTexture rt = New RenderTexture(1300, 760, 24)

camera.targetTexture = rt

camera:Render()

RenderTexture.active = rt

t2d:ReadPixels(New Rect(0, 0, rt.width, rt.height), 0, 0)

t2d:Apply()

RenderTexture.active = null

camera.targetTexture = null

Sprite spr = Sprite.Create(t2d,New Rect(0, 0, rt.width, rt.height), New Vector2(0, 0))

sprRender.sprite = spr

--将图片保存起来

byte[] byts = t2d:EncodeToJPG()

WriteAllBytesToFile(Application.dataPath .. "//" .. "currentMap.jpg", tostring(byts))

上一篇:趋势已成:未来5年AI在银行业的5大应用


下一篇:风口上的区块链,微众银行如何让技术应用落地?