Version: 2022.2
言語: 日本語
public void SetPixels (Color[] colors, int arrayElement, int miplevel);
public void SetPixels (Color[] colors, int arrayElement);

パラメーター

colors The array of pixel colours to use. This is a 2D image flattened to a 1D array.
arrayElement The array slice to write to.
miplevel The mipmap level to write colors to. The range is 0 through the texture's Texture.mipmapCount. The default value is 0.

説明

Sets the pixel colors of an entire mipmap level of a slice.

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.

Apply is an expensive operation because it copies all the pixels in the texture even if you've only changed some of the pixels, so change as many pixels as possible before you call it.

colors must contain the pixels row by row, starting at the bottom left of the texture. The size of the array must be the width × height of the mipmap level.

SetPixels might be slower than some other texture methods because it converts the Color struct into the format the texture uses. To set pixel data more quickly, use SetPixelData instead.

You can use SetPixels with the following texture formats: Alpha8 ARGB32 ARGB4444 BGRA32 R16 R8 RFloat RG16 RG32 RGB24 RGB48 RGB565 RGB9e5Float RGBA32 RGBA4444 RGBA64 RGBAFloat RGBAHalf RGFloat RGHalf RHalf For all other formats, SetPixels fails. Unity throws an exception when SetPixels fails.

See Also: GetPixels, SetPixels32, SetPixelData, Apply, mipmapCount.