コード例 #1
0
        private void UpdateTouches()
        {
            if (Input.touchCount > 0)
            {
                Touch touch = Input.GetTouch(0);
                switch (touch.phase)
                {
                case TouchPhase.Began:
                    Touches      = new Queue <MobileTouch>();
                    CurrentTouch = new MobileTouch(touch, true);
                    ReferenceCameraSnapshot.CopyFrom(ReferenceCamera);
                    break;

                case TouchPhase.Moved:
                    if (Touches.Count == 0 || Vector2.Distance(touch.position, CurrentTouch.Position) > DistanceBetweenTouches)
                    {
                        Touches.Enqueue(new MobileTouch(touch, true));
                    }
                    break;

                case TouchPhase.Ended:
                    Touches.Enqueue(new MobileTouch(touch, false));
                    break;
                }
            }
        }
コード例 #2
0
        private Vector3 WorldPositionFromTouchPosition(Vector2 touchPosition)
        {
            Vector3    worldPosition = new Vector3(0, 0, 0);
            Ray        positionRay   = ReferenceCameraSnapshot.ScreenPointToRay(touchPosition);
            RaycastHit hit;

            if (Physics.Raycast(positionRay, out hit))
            {
                worldPosition = hit.point;
            }
            return(worldPosition);
        }