Skip to content

Api > Texture2D > SetPixels()


Texture2D.SetPixels(Color[] colors, number miplevel = 0)⚓︎

Sets the pixel colors of an entire mipmap level.

Parameters:⚓︎

Name Type Description
colors Color[] The array of pixel colours to use. This is a 2D image flattened to a 1D array.
miplevel number The mipmap level to write colors to. The range is 0 through the texture's Texture.mipmapCount. The default value is 0.

Usage⚓︎

---@type Texture2D
local texture2d;

---@type Color
local colors;

---@type number
local miplevel;


texture2d.SetPixels(colors, 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 SetPixels to upload the changed pixels to the GPU.