コード例 #1
0
    private void DoMobileInput()
    {
        if (Touching)
        {
            // Cache first touch this frame
            Touch fTouch = FirstTouch;
            // Cache position info too
            Vector2 pos = fTouch.position;

            // Invoke events
            switch (fTouch.phase)
            {
            case TouchPhase.Began:
                OnFirstTouchStart?.Invoke(pos);
                break;

            case TouchPhase.Stationary:
            case TouchPhase.Moved:
                OnFirstTouchMoved?.Invoke(pos, fTouch.deltaPosition);
                break;

            case TouchPhase.Ended:
                OnFirstTouchEnd?.Invoke(pos);
                break;
            }
        }
    }
コード例 #2
0
    private void DoKeyboardInput()
    {
        // Cache position info too
        Vector2 pos = Input.mousePosition;

        // Invoke events
        if (Input.GetMouseButtonDown(0))
        {
            OnFirstTouchStart?.Invoke(pos);
        }
        else if (Input.GetMouseButton(0))
        {
            OnFirstTouchMoved?.Invoke(pos, Vector2.zero);
        }
        else if (Input.GetMouseButtonUp(0))
        {
            OnFirstTouchEnd?.Invoke(pos);
        }
    }