Format
typescript
RenderTexture.SetPixels(x, y, blockWidth, blockHeight, colors, 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. |
| colors | Color[] | An array of pixel colors for the block. |
| mipLevel | number? | The mipmap level. |
Return
| type | description |
|---|---|
void |
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);
}
}