Ejemplo n.º 1
0
    void Update()
    {
        _moveInput = Vector2.zero;

        if (inputCallback != null)
        {
            inputCallback.Invoke();
        }

        correction = Vector2.zero;
    }
Ejemplo n.º 2
0
        public void ReceiveInput(BA_InputType type)
        {
            if (!IsInputValid(type))
            {
                return;
            }

            if (type == BA_InputType.MOUSE_0_DOWN)
            {
                //float timeT = Time.time;

                int pointerID = -1;

                _ped = _inputModule.GetLastPointerEventDataCustom(pointerID);

                if (_ped == null)
                {
                    Debug.Log("ped is null in " + type + " ==  " + pointerID);
                }

                _raycastResults.Clear();

                _gRaycaster.Raycast(_ped, _raycastResults);

                //Debug.Log("raycast:" + (Time.time - timeT));

                //Debug.Log("raycast end:" + Time.time);

                //Move
                if (_raycastResults.Count == 0)
                {
                    MoveInputVector3(_pointerPosition);
                }
                //Delegate to UI Input Receiver
                else
                {
                    MouseInputUI(_ped);
                }
            }
            else if (type == BA_InputType.GAMEPAD_0_DOWN || type == BA_InputType.KEYBOARD_0_DOWN)
            {
                ActionKey?.Invoke();
            }
            else if (type == BA_InputType.GAMEPAD_1_DOWN)
            {
                float gamepadToScreenPoint_x = (Screen.width / 2) + Screen.width * _gamepadRight.x;
                float gamepadToScreenPoint_y = (Screen.height / 2) + Screen.height * _gamepadRight.y;

                ActionKey_2?.Invoke(new Vector2(gamepadToScreenPoint_x, gamepadToScreenPoint_y));
            }
            else if (type == BA_InputType.KEYBOARD_1_DOWN)
            {
                ActionKey_2?.Invoke(_pointerPosition);
            }
            else if (type == BA_InputType.TOUCH_0_UP)
            {
                _ped          = new PointerEventData(EventSystem.current);
                _ped.position = _pointerPosition;
                //_ped = _inputModule.GetLastPointerEventDataCustom(_currentFingerID);

                if (_ped == null)
                {
                    Debug.Log("ped is null in touch up");
                    Debug.Log("fingerID: " + _currentFingerID);
                }

                _raycastResults.Clear();

                _gRaycaster.Raycast(_ped, _raycastResults);

                foreach (var result in _raycastResults)
                {
                    if (result.gameObject.GetComponent <BA_BaseUIElement>() != null)
                    {
                        _ped.pointerEnter = result.gameObject;
                    }
                }

                if (_raycastResults.Count == 0)
                {
                    MoveInputVector3(_pointerPosition);
                }
                else
                {
                    TouchInputUI(_ped);
                }
            }
        }