Finding pixel on sprite in Unity

寵の児 提交于 2019-12-10 22:41:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!