Skip to content

Format

typescript
Texture2D.GetPixels(x, y, blockWidth, blockHeight, mipLevel)

class: Texture2D

Description

Get the pixel color of a specific area on a texture.

It can be used to read the color information of a specific area in a texture, allowing you to retrieve the pixel data of the texture at runtime.

Parameters

param_nametypedescription
xnumberThe x-axis coordinate.
ynumberThe y-axis coordinate.
blockWidthnumberThe width of the area to be retrieved.
blockHeightnumberThe height of the area to be retrieved.
mipLevelnumber?The mip level of the texture.

Return

typedescription
Color|undefinedAn array of pixel colors.

Code Example