将 TUIO 触摸输入转换为 UNITY 触摸

Converting TUIO Touch Inputs to UNITY touches

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

/// 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);
    }
}

很像。看看 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);
    }
}