GetPixel is not working.

Hi,

I’ve create a draw3d texture using jpg file but getpixel() is not working perfectly.

Here is my script

            Vector2 pickpos = Event.current.mousePosition;
            int aaa = (int)(pickpos.x);
            int bbb = (int)(pickpos.y);
            
            Color col = colorPicker.GetPixel(aaa, bbb);
            
            GameObject gdata = GameObject.Find("gDomino");
            gdata.renderer.material.color = col;

It’s not fetching pixel of related color.I show different color

thanks for support

Do you know that JPG is a lossy compression algorithm? You should use a lossless compressed image such as PNG. And then set the texture image type to true color (not compressed).

You probably just need to invert the y-coordinate since a texture is build up from bottom to top:

        Vector2 pickpos = Event.current.mousePosition;
        int aaa = (int)(                pickpos.x - irect.x);
        int bbb = (int)(irect.height - (pickpos.y - irect.y));

I’ve also subtracted the pivot of your rect just in case you move the picker somewhere else on the screen.