Untitled

mail@pastecode.io avatar
unknown
csharp
14 days ago
1.6 kB
1
Indexable
Never
    private static Camera mainCamera;

    private Vector2 _delta;
    private Vector2 _pointerPosition;
    
    private bool _isMoving;
    private bool _isZooming;
    private bool _isDragging;
    private bool _isLongPressed;

    /// <summary>
    /// Update _delta (direction and rate of change of the pointer) value
    /// </summary>
    /// <param name="context"></param>
    public void OnLook(InputAction.CallbackContext context)
    {
        _delta = context.ReadValue<Vector2>();
    }

    /// <summary>
    /// Update _pointer position
    /// </summary>
    /// <param name="context"></param>
    public void OnPosition(InputAction.CallbackContext context)
    {
        _pointerPosition = context.ReadValue<Vector2>();
    }

    /// <summary>
    /// Check if zoom being initiated
    /// </summary>
    /// <param name="context"></param>
    public void OnScroll(InputAction.CallbackContext context){
        _isZooming = context.performed;
        if (_isZooming) _zoomDelta = context.ReadValue<Vector2>();
    }

    /// <summary>
    /// Check if the pointer is long pressing
    /// </summary>
    /// <param name="context"></param>
    public void OnLongPress(InputAction.CallbackContext context){
        if(context.performed){_isLongPressed = true;}
    }

    /// <summary>
    /// Check if the pointer is moving
    /// </summary>
    /// <param name="context"></param>

    public void OnDrag(InputAction.CallbackContext context){
        if(!_isMoving){return;}
        if(context.performed){
        _isDragging = true;
        }
    }
Leave a Comment