Format
typescript
RenderTexture.GetPixels(x, y, blockWidth, blockHeight, mipLevel)class: RenderTexture
Description
Get the pixel color of the block with a width of blockWidth and a height of blockHeight at the coordinates (x, y) in the upper right corner.
Parameters
| param_name | type | description |
|---|---|---|
| x | number | The x-axis coordinate. |
| y | number | The y-axis coordinate. |
| blockWidth | number | The width of the block. |
| blockHeight | number | The height of the block. |
| mipLevel | number? | The mipmap level. |
Return
| type | description |
|---|---|
Color|undefined | Returns the color array if successful, otherwise returns undefined. |
Code Example
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);
}
}