Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Joe @ ByDesign Games on June 21, 2013, 12:14:16 AM

Title: Get texture's pixel coordinates when touching a UITexture?
Post by: Joe @ ByDesign Games on June 21, 2013, 12:14:16 AM
Have a need to get a texture's pixel coords from touching a UITexture.

Have tried a variety of approaches to no result.

Anyone know how to do this reliably?
Title: Re: Get texture's pixel coordinates when touching a UITexture?
Post by: Joe @ ByDesign Games on June 21, 2013, 02:21:47 PM
Adding, have also tried using RaycastHit.textureCoords but that requires a mesh collider (no other collider is supported) and considering UITexture doesn't expose it's mesh, it's not working.

How else to do this?
Title: Re: Get texture's pixel coordinates when touching a UITexture?
Post by: ArenMook on June 22, 2013, 06:07:15 AM
Math. You know a 3D click point on the collider. Use the widget's transform.InverseTransformPoint to make it local. Divide by width/height. May or may not have to flip the Y (1 - y).
Title: Re: Get texture's pixel coordinates when touching a UITexture?
Post by: Joe @ ByDesign Games on June 22, 2013, 06:18:39 AM
Ahh right, infer from the collision point; for some reason thought texture coords couldn't be derived that way.

Thanks Michael!