Description
The GetPixel
method retrieves the color of a specific pixel from a texture at a given mipmap level. The pixel is specified by its normalized coordinates x
and y
, where both values range from 0 to 1, representing the relative position within the texture. The mip
parameter specifies the mipmap level to sample from, with 0 being the highest resolution level.
Usage
To use the GetPixel
method, you need to have an instance of a Texture
object. Call the method with the desired normalized coordinates and mipmap level to obtain the color of the pixel at that location.
Example
// Assume 'texture' is a valid Texture instance
float x = 0.5f; // Normalized x-coordinate
float y = 0.5f; // Normalized y-coordinate
int mipLevel = 0; // Mipmap level
Color32 pixelColor = texture.GetPixel(x, y, mipLevel);
// Use pixelColor as needed