Skip to main content

Texture2D.SetPixel(number x, number y, Color color, number mipLevel = 0)

Sets the pixel color at coordinates (x,y).

Parameters:

NameTypeDescription
xnumberThe x coordinate of the pixel to set. The range is 0 through (texture width - 1).
ynumberThe y coordinate of the pixel to set. The range is 0 through (texture height - 1).
colorColorThe color to set.
mipLevelnumberThe mipmap level to write to. The range is 0 through the texture's Texture.mipmapCount. The default value is 0.

Usage

---@type Texture2D
local texture2d;

---@type number
local x;

---@type number
local y;

---@type Color
local color;

---@type number
local mipLevel;


texture2d.SetPixel(x, y, color, mipLevel)

Extra Detail

This method sets pixel data for the texture in CPU memory. Texture.isReadable must be true, and you must call Apply after SetPixel to upload the changed pixels to the GPU.