【问题标题】:Converting TUIO Touch Inputs to UNITY touches将 TUIO 触控输入转换为 UNITY 触控
【发布时间】:2018-03-07 15:15:15
【问题描述】:

如果不使用 TUIO 触摸和 UNITY 触摸,那么下面的函数会是什么样子?

/// Fingers touch.
/// </summary>
private void FingerTouch ()
{
    var beganTouches = from Tuio.Touch t in TuioTrackingComponent.Touches.Values
        where t.Status == TouchStatus.Began
            select t;

    // Raycast and attached springs to the hit objects
    foreach (Tuio.Touch t in beganTouches) {    
        if (Physics.Raycast (Camera.main.ScreenPointToRay (new Vector3 (t.TouchPoint.x, t.TouchPoint.y, 0f)), out hit)) {
            if (hit.collider != null && hit.transform.gameObject.CompareTag ("FishCollider")) {
                touchedFishes.Add (t.TouchId, hit.transform.parent.gameObject);
                isHolding = true;
            }
        }
        MoveFish (t);
    }
}

【问题讨论】:

    标签: c# unity3d touch


    【解决方案1】:

    非常相似。看看documentation:

    foreach (Touch touch in Input.touches)
    {
        if (touch.phase == TouchPhase.Began)
        {
            if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0f)), out hit))
            {
                if (hit.collider != null && hit.transform.gameObject.CompareTag("FishCollider"))
                {
                    touchedFishes.Add(touch.fingerId, hit.transform.parent.gameObject);
                    isHolding = true;
                }
            }
            MoveFish(touch);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多