Beispiel #1
0
    private void Update()
    {
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; ++i)
            {
                ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);

                if (Physics.Raycast(ray, out rayHit, Mathf.Infinity))
                {
                    if (Input.GetTouch(i).phase == TouchPhase.Began)
                    {
                        dad.CardTouched(ray, rayHit);
                    }
                    else if (Input.GetTouch(i).phase == TouchPhase.Moved)
                    {
                        if (activeCard == null)
                        {
                            return;
                        }

                        dad.Drag(ray, rayHit);
                    }
                    else if (Input.GetTouch(i).phase == TouchPhase.Ended || Input.GetTouch(i).phase == TouchPhase.Canceled)
                    {
                        if (activeCard == null)
                        {
                            return;
                        }

                        dad.Drop(ray, rayHit);
                    }
                }
            }
        }
        else
        {
            activeCard = null;
        }
    }