- Home /
Canvas UI - Get Pixel Colour from Image
Hello,
I want to get the pixel colour of the image that has been selected within Canvas UI. If I was using a normal Physics Raycaster, I would use 'hit.textureCoord', however I can't seem to access the 'hit' of the UI Graphics Raycaster.
This is called when the image is tapped on;
public void OnTapImage(BaseEventData _data){
PointerEventData _pointer = _data as PointerEventData;
}
'_pointer' has 'pointerCurrentRaycast' as a sub-class, but it doesn't seem to have much regarding the Hit data, thus I cannot get 'textureCoord'. (unless I'm missing something?).
I could use mousePosition, and grab the pixel data it is currently over, but this will not work for Alpha/Transparent data. And this is key! I need to be able to check what the alpha level is on the image the user is selecting.
Any ideas? Thanks.
Your answer
Follow this Question
Related Questions
Pull Color from pixel of a an invisible texture from Raycast. 1 Answer
Get pixel from Rotated Texture2D 1 Answer
Find TextureCoordinates from plane with out raycast only using mouse position on plan 0 Answers
Multi Coloured Buttons 0 Answers
Is it possible to configure raycast to hit opaque pixels without using alphaHitTestMinimumThreshold? 1 Answer