Texture2D.GetPixels32 获取32位像素颜色列表
function GetPixels32 (miplevel : int = 0) : Color32[]
Description描述
Get a block of pixel colors in Color32 format
获取Color32格式的像素颜色块。
This function returns an array of pixel colors of the whole mip level of the texture.
这个函数返回整个纹理mip level的像素颜色数组。
The returned array is a flattened 2D array, where pixels are laid out left to right, bottom to top (i.e. row after row). Array size is width by height of the mip level used. The default mip level is zero (the base texture) in which case the size is just the size of the texture. In general case, mip level size is mipWidth=max(1,width>>miplevel) and similarly for height.
返回的数组是二维数组,像素布局从左到右,从底到顶(即,一行行),数组的大小是使用mip level的宽乘高。默认的mip level为0(基本纹理),这时候数组的大小是纹理的大小。在一般情况下,mip level大小是mipWidth=max(1,width>>miplevel) ,高度也同样。
The texture must have the Is Readable flag set in the import settings, otherwise this function will fail.
纹理必须在导入设置中具有Is Readable可读标识,否则这个函数将失败。
Using GetPixels32 can be faster than calling GetPixel32 repeatedly, especially for large textures. In addition, GetPixels32 can access individual mipmap levels.
使用GetPixels32比重复调用GetPixel32执行更快,尤其对于大纹理。此外,GetPixels32可以访问单个mipmap levels。
参见:SetPixels, mipmapCount.