格式
typescript
RenderTexture.SetPixels(x, y, blockWidth, blockHeight, colors, mipLevel)所属类: RenderTexture
描述
获取右上角坐标 (x, y) 处blockWidth宽blockHeight高区块的像素颜色。
参数
| 参数名 | 类型 | 描述 |
|---|---|---|
| x | number | x轴坐标 |
| y | number | y轴坐标 |
| blockWidth | number | 区块宽度 |
| blockHeight | number | 区块高度 |
| colors | Color[] | 区块像素颜色数组 |
| mipLevel | number? | mipmap级别 |
返回值
| 类型 | 描述 |
|---|---|
void |
代码示例
typescript
function Test() {
try {
let temp_texture = RenderTexture.GetTemporary(100, 100, RenderTextureFormat.Default, DepthType.Depth24Stencil8, AntiAliasingLevel.x8);
let color_array:Color[] = new Array(60*60);
for (let i = 0; i < color_array.length; ++i) {
color_array[i] = Color.cyan;
}
texture.SetPixels(20, 20, 60, 60, color_array, 0);
let color_array_test = texture.GetPixels(20, 20, 60, 60, 0);
} catch (error) {
Debug.Log(error);
}
}