Texture2D.ReadPixels 读取像素

function ReadPixels (source : Rect, destX : int, destY : int, recalculateMipMaps : bool = true) : void

Read screen pixels into the saved texture data.


This will copy a rectangular pixel area from the currently active RenderTexture or the view (specified by /source/) into the position defined by destX and destY. Both coordinates use pixel space - (0,0) is lower left.

这将从当前处于激活状态的 RenderTexture 或视图(由/source/指定)复制一个由destX和destY指定的矩形像素区域。这两个坐标使用像素空间坐标 (0,0)是屏幕左下角。

If recalculateMipMaps is set to true, the mip maps of the texture will also be updated. If recalculateMipMaps is set to false, you must call Apply to recalculate them.

如果 recalculateMipMaps 设置为真,这个贴图的mipmaps就会更新

如果 recalculateMipMaps设置为假,你需要调用Apply重新计算它们

This function works only on ARGB32 and RGB24 texture formats. The texture also has to have Is Readable flag set in the import settings.

这个函数只工作在格式为ARGB32 和 RGB24纹理上,另外这个纹理的导入设置需要设置为 Is Readable(可读)

参见: EncodeToPNG .

Page last updated: 2010-12-18