Skip to content

Format

typescript
Texture2D.SetPixel(x, y, col, mipLevel)

class: Texture2D

Description

Sets the color of a specific pixel at a given position on the texture.

Parameters

param_nametypedescription
xnumberThe x-axis coordinate.
ynumberThe y-axis coordinate.
colColorThe color of the pixel.
mipLevelnumberThe mip level of the texture.

Return

typedescription
void

Code Example

typescript
let uuid = "31A9092E126B4B19BBFD9D5FCD75AA49";
let tex = Resources.Load<Texture2D>(Texture2D, uuid);
if (tex == null) {
    throw new Exception("failed to load texture2d: " + uuid);
}

tex.SetPixel(0, 0, Color.red, 0);