Hi, I'm having trouble from taking the screen coordinates of a UI element and using them to find the equivalent texture coordinates of an image behind.
I have the screen coordinates of a UI Rect Transform by just doing RectTransform.Position, and I have a RawImage below, which is showing a WebCamTexture, which is captured from my device camera.
In order to run GetPixel on the texture to get the colour underneath the UI element, I need the UV/Texture coords, but I have tried everything to convert between Screen to Texture but I've had no luck. Just wondering the best way to do so.
Thanks - let me know if you need to see any code.
the image behind is also a UI element, just to avoid any confusion
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
3 People are following this question.
Why would my texture split across the triangle at runtime?
How to get the actual World Positions of the Corners of an UI element when using GetWorldCorners if Canvas is set to Screen Space - World
How to get precise pixel values form a Texture2D using uv coordinates.
UI interaction is acting really strange on android
Create Image on ground.