【问题标题】:UNITY touch position to world position 2DUNITY 触摸位置到世界位置 2D
【发布时间】:2014-10-14 19:59:46
【问题描述】:

如何将触摸位置(在手机上)转换为世界位置。例如,如果我的手机屏幕尺寸是 1440 x 2560,而我在手机上的触摸位置是 X 600 Y 700。我如何将该位置转换为统一的世界位置?

我需要它,这样我才能知道用户将手指放在哪里。

【问题讨论】:

    标签: android unity3d touch 2d screen


    【解决方案1】:

    已经有一种方法可以为您做到这一点。看看Camera.ScreenToWorldPoint

    一旦您参考了所需的相机,您就可以像这样使用它:

    Vector2 touchPos = Input.touches[0].position;
    
    Vector3 touchPosinWorldSpace = camera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, camera.nearClipPlane));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-01
      • 2018-03-04
      • 2018-07-04
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      相关资源
      最近更新 更多