Example #1
0
    void TouchManager()
    {
        if (Input.touchCount > 0)
        {
            GetTouchPosition();

            if (previousTouchPhase == TouchPhase.Stationary && m_Touch.phase == TouchPhase.Ended && !startMoving)
            {
                Debug.Log("TAP");
                startMoving = true;
            }

            else if (m_Touch.phase == TouchPhase.Moved && !isCutting)
            {
                m_Blade.StartCutting(touchPosition);
                isCutting = true;
                Debug.Log("START CUTTING");
            }

            else if (m_Touch.phase == TouchPhase.Ended && isCutting)
            {
                m_Blade.StopCutting();
                isCutting = false;
                Debug.Log("STOP CUTTING");
            }

            if (isCutting)
            {
                m_Blade.UpdateCut(touchPosition);
                Debug.Log("CUTTING");
            }

            previousTouchPhase = m_Touch.phase;
        }

        else if (isCutting)
        {
            m_Blade.StopCutting();
            isCutting = false;
            Debug.Log("STOP CUTTING");
        }
    }
 public virtual void OnPointerDown(PointerEventData eventData)
 {
     origin = eventData.position;
     blade.UpdatePosition(origin);
     blade.StartCutting();
 }