Ope*_*L97 5 android 2d screen touch unity-game-engine
如何将触摸位置(在手机上)转换为世界位置。例如,如果我的手机屏幕尺寸是 1440 x 2560,而我在手机上的触摸位置是 X 600 Y 700。我如何才能将该位置转换为统一的世界位置?
我需要它,这样我才能知道用户将手指放在哪里。
有一种方法已经可以为您做到这一点。看看Camera.ScreenToWorldPoint。
一旦您获得了所需相机的参考,您就可以像这样使用它:
Vector2 touchPos = Input.touches[0].position;
Vector3 touchPosinWorldSpace = camera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, camera.nearClipPlane));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5569 次 |
| 最近记录: |