private void multiTouch()
        {
            Touch a = Input.GetTouch(0);
            Touch b = Input.GetTouch(1);

            if ((a.phase == TouchPhase.Stationary || a.phase == TouchPhase.Moved) &&
                (b.phase == TouchPhase.Stationary || b.phase == TouchPhase.Moved))
            {
                Ray ray = cam.ScreenPointToRay(a.position);

                // There are hitting objects..
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, kRaycastLayers))
                {
                    float d = Vector2.Distance(a.position, b.position);
                    if (touchState != TouchToMouseState.Pinching)
                    {
                        _touchesDistance = d;
                        toPinchStart();
                        touchState = TouchToMouseState.Pinching;
                    }
                    else
                    {
                        toPinch(d / _touchesDistance);
                    }
                }
                else
                {
                }
            }
        }
        void Update()
        {
            if (!isOn)
            {
                return;
            }
            int count = Input.touchCount;

            if (count == 1)
            {
                if (touchState == TouchToMouseState.Pinching)
                {
                    touchState = TouchToMouseState.PinchEnd;
                    toPinchEnd();
                }
                else if (touchState == TouchToMouseState.PinchEnd)
                {
                    // nothing to do
                }
                else
                {
                    singleTouch();
                }
            }
            else if (count >= 2)
            {
                multiTouch();
            }
            else
            {
                noTouch();
            }
            callGC();
        }
 private void noTouch()
 {
     if (touchState == TouchToMouseState.Pinching)
     {
         touchState = TouchToMouseState.PinchEnd;
     }
     else if (touchState == TouchToMouseState.PinchEnd)
     {
         touchState = TouchToMouseState.Up;
     }
     else if (beforeTransform)
     {
         toMouseExit();
     }
 }
 private void toUp()
 {
     hit.transform.SendMessage("OnMouseUp", null, SendMessageOptions.DontRequireReceiver);
     touchState = TouchToMouseState.Up;
     beforeTransform = null;
 }
 private void toDrag()
 {
     hit.transform.SendMessage("OnMouseDrag", null, SendMessageOptions.DontRequireReceiver);
     touchState = TouchToMouseState.Drag;
     beforeTransform = hit.transform;
 }
 private void noTouch()
 {
     if (touchState == TouchToMouseState.Pinching)
     {
         touchState = TouchToMouseState.PinchEnd;
     }
     else if (touchState == TouchToMouseState.PinchEnd)
     {
         touchState = TouchToMouseState.Up;
     }
     else if (beforeTransform)
     {
         toMouseExit();
     }
 }
        private void multiTouch()
        {
            Touch a = Input.GetTouch(0);
            Touch b = Input.GetTouch(1);
            if ((a.phase == TouchPhase.Stationary || a.phase == TouchPhase.Moved)
             && (b.phase == TouchPhase.Stationary || b.phase == TouchPhase.Moved))
            {
                Ray ray = cam.ScreenPointToRay(a.position);

                // There are hitting objects..
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, kRaycastLayers))
                {
                    float d = Vector2.Distance(a.position, b.position);
                    if (touchState != TouchToMouseState.Pinching)
                    {
                        _touchesDistance = d;
                        toPinchStart();
                        touchState = TouchToMouseState.Pinching;
                    }
                    else
                    {
                        toPinch(d / _touchesDistance);
                    }
                }
                else
                {

                }
            }
        }
 void Update()
 {
     if (!isOn)
     {
         return;
     }
     int count = Input.touchCount;
     if (count == 1)
     {
         if (touchState == TouchToMouseState.Pinching)
         {
             touchState = TouchToMouseState.PinchEnd;
             toPinchEnd();
         }
         else if (touchState == TouchToMouseState.PinchEnd)
         {
             // nothing to do
         }
         else
         {
             singleTouch();
         }
     }
     else if (count >= 2)
     {
         multiTouch();
     }
     else
     {
         noTouch();
     }
     callGC();
 }
 private void toUp()
 {
     hit.transform.SendMessage("OnMouseUp", null, SendMessageOptions.DontRequireReceiver);
     touchState      = TouchToMouseState.Up;
     beforeTransform = null;
 }
 private void toDrag()
 {
     hit.transform.SendMessage("OnMouseDrag", null, SendMessageOptions.DontRequireReceiver);
     touchState      = TouchToMouseState.Drag;
     beforeTransform = hit.transform;
 }