Color32[] GetPixels( int mip )
void GetPixels( System.ValueTuple<int, int, int, int> srcRect, int slice, int mip, System.Span<T> dstData, ImageFormat dstFormat, System.ValueTuple<int, int> dstSize )
void GetPixels( System.ValueTuple<int, int, int, int> srcRect, int slice, int mip, System.Span<T> dstData, ImageFormat dstFormat, System.ValueTuple<int, int, int, int> dstRect, int dstStride )

book_4_sparkGenerated
code_blocksInput

Description

The GetPixels method retrieves the color data of a specified mipmap level from a texture. It returns an array of Color32 objects, each representing a pixel's color in the texture at the specified mipmap level.

Usage

To use the GetPixels method, call it on an instance of the Texture class, passing the desired mipmap level as an integer parameter. The method will return an array of Color32 objects, which you can then use to analyze or manipulate the texture's pixel data.

Ensure that the mipmap level you specify is valid for the texture. The number of mipmap levels available can be determined by the Mips property of the Texture class.

Example

// Example of using GetPixels to retrieve pixel data from a texture
Texture texture = ...; // Assume this is an initialized texture
int mipLevel = 0; // Specify the mipmap level you want to access

// Retrieve the pixel data for the specified mipmap level
Color32[] pixels = texture.GetPixels(mipLevel);

// Iterate over the pixel data
foreach (Color32 pixel in pixels)
{
    // Process each pixel's color data
    // For example, print the color values
    // Console.WriteLine($"R: {pixel.r}, G: {pixel.g}, B: {pixel.b}, A: {pixel.a}");
}