SetPixels
Sets the pixel colors of an entire mipmap level of a face of a slice.
Read time 3 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
SetPixels(Color[], CubemapFace, int, int)
Sets the pixel colors of an entire mipmap level of a face of a slice.
public void SetPixels(Color[] colors, CubemapFace face, int arrayElement, int miplevel)
Parameters
The array of pixel colours to use. This is a 2D image flattened to a 1D array.
The CubemapFace to write to.
colorsThe array slice to write to.
colorsThe mipmap level to write to. The range is through the texture's Texture.mipmapCount. The default value is .
colors00Remarks
This method sets pixel data for the texture in CPU memory. Texture.isReadable must be , and you must call CubemapArray.Apply after to upload the changed pixels to the GPU.
trueSetPixelsCubemapArray.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.
colorsSetPixelsYou can use with the following texture formats:
SetPixels- Alpha8
- ARGB32
- ARGB4444
- BGRA32
- R16
- R16_SIGNED
- R8
- R8_SIGNED
- RFloat
- RG16
- RG16_SIGNED
- RG32
- RG32_SIGNED
- RGB24
- RGB24_SIGNED
- RGB48
- RGB48_SIGNED
- RGB565
- RGB9e5Float
- RGBA32
- RGBA32_SIGNED
- RGBA4444
- RGBA64
- RGBA64_SIGNED
- RGBAFloat
- RGBAHalf
- RGFloat
- RGHalf
- RHalf
For all other formats, fails. Unity throws an exception when fails.
SetPixelsSetPixelsAdditional Resources: CubemapArray.GetPixels, CubemapArray.SetPixels32, CubemapArray.SetPixelData, CubemapArray.Apply, mipmapCount.
SetPixels(Color[], CubemapFace, int)
Sets the pixel colors of an entire mipmap level of a face of a slice.
public void SetPixels(Color[] colors, CubemapFace face, int arrayElement)
Parameters
The array of pixel colours to use. This is a 2D image flattened to a 1D array.
The CubemapFace to write to.
colorsThe array slice to write to.
colorsRemarks
This method sets pixel data for the texture in CPU memory. Texture.isReadable must be , and you must call CubemapArray.Apply after to upload the changed pixels to the GPU.
trueSetPixelsCubemapArray.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.
colorsSetPixelsYou can use with the following texture formats:
SetPixels- Alpha8
- ARGB32
- ARGB4444
- BGRA32
- R16
- R16_SIGNED
- R8
- R8_SIGNED
- RFloat
- RG16
- RG16_SIGNED
- RG32
- RG32_SIGNED
- RGB24
- RGB24_SIGNED
- RGB48
- RGB48_SIGNED
- RGB565
- RGB9e5Float
- RGBA32
- RGBA32_SIGNED
- RGBA4444
- RGBA64
- RGBA64_SIGNED
- RGBAFloat
- RGBAHalf
- RGFloat
- RGHalf
- RHalf
For all other formats, fails. Unity throws an exception when fails.
SetPixelsSetPixelsAdditional Resources: CubemapArray.GetPixels, CubemapArray.SetPixels32, CubemapArray.SetPixelData, CubemapArray.Apply, mipmapCount.