- Home /
Analyse Textures first pixel
Is there a way i can store the first pixel in an image texture to a variable? How would I analyse it?
Answer by maccabbe · Feb 27, 2015 at 07:22 AM
Use GetPixel to get any pixel in a texture. (http://docs.unity3d.com/ScriptReference/Texture2D.GetPixel.html)
Texture2D texture;
Color color=texture.GetPixel(0, 0);
Each pixel is a color value and you can analyze it as such.
how can i get the textures bottom right (last) pixel if 0, 0 is the first pixel?
You would use the code
Texture2D texture;
Color lastColor=texture.GetPixel(texture.width-1, texture.height-1);
You subtract 1 from width and height because in C#, like many languages the 1st element is in the 0th position so the texture.width element is in the texture.width-1 position.
Your answer
![](https://koobas.hobune.stream/wayback/20220613184455im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get texture pixels under a plane 1 Answer
get pixel from a texture 1 Answer
Perfect 2d image 1 Answer
Texture Quality VS (Sprite 2D and UI) Quality 1 Answer
How can i avoid mouse clicking on alpha areas in my GUITexture? 1 Answer