问题
In Unity3d we have RaycastHit.textureCoord
but it doesn't exist anymore in 2D. I was searching about this problem, a lot but I didn't find anything useful.
So I want to know the solution for this problem and I'm wondering why method like textureCoord in 3D doesn't exist in 2D actually in RaycastHit2D
.
also I want to access to the pixel when mouse cursor on it.
回答1:
It works in 3D because RaycastHit.textureCoord
requires a mesh collider. In the 2D case it is way simplee because you can calculate the position yourself as you know the sprite hit, the cursor position and size of the sprite.
来源:https://stackoverflow.com/questions/30016974/finding-pixel-on-sprite-in-unity