Example #1
0
    //Todo: add virtualbuttons from axis

    private void CheckAxisInput()
    {
        for (int i = 0; i < axes.Length; i++)
        {
            float value = CheckAxis(axes[i].ActiveController);
            if (Mathf.Abs(value) >= axisDeadZone)
            {
                onAxisInput.Invoke(axes[i].BindName, value);
                continue;
            }
            if (axes[i].IsAxis)
            {
                value = CheckAxis(axes[i].ActiveAxis);
            }
            else
            {
                value = CheckVirtualAxis(axes[i].ActivePositive, axes[i].ActiveNegative);
            }
            if (Mathf.Abs(value) >= axisDeadZone)
            {
                onAxisInput.Invoke(axes[i].BindName, value);
                continue;
            }
        }
    }
Example #2
0
        void DebugInputAxes()
        {
            // Loop in reverse to avoid errors when removing invalid names.
            for (int i = m_AxisNames.Count - 1; i >= 0; i--)
            {
                try
                {
                    m_AxisValue = Input.GetAxis(m_AxisNames[i]);
                }
                catch
                {
                    Debug.LogWarningFormat("Input Manager does not contain an axis named \"{0}\".", m_AxisNames[i]);
                    m_AxisNames.RemoveAt(i);
                    continue;
                }

                if (m_AxisValue != 0f)
                {
                    if (logInputAxisValues)
                    {
                        Debug.Log(string.Format("Input axis \"{0}\" is active ({1}).", m_AxisNames[i], m_AxisValue));
                    }

                    if (onAxisInput != null)
                    {
                        onAxisInput.Invoke(m_AxisNames[i], m_AxisValue);
                    }
                }
            }
        }
Example #3
0
        void Update()
        {
            if (!m_Inited)
            {
                return;
            }

            m_InputX = GetAxis(Constant.Input.HorizontalAxis);
            m_InputY = GetAxis(Constant.Input.VerticalAxis);

            if (Mathf.Abs(m_InputX) > 0.05f || Mathf.Abs(m_InputY) > 0.05f)
            {
                OnAxisInput?.Invoke(new Vector2(m_InputX, m_InputY));
                m_LastInputEnable = true;
            }
            else
            {
                if (m_LastInputEnable)
                {
                    OnAxisInputEnd?.Invoke();
                }
                m_LastInputEnable = false;
            }

            if (GetButtonDown(Constant.Input.KeyNum01))
            {
                OnSkillClick?.Invoke(1);
            }
            if (GetButtonDown(Constant.Input.KeyNum02))
            {
                OnSkillClick?.Invoke(2);
            }
            if (GetButtonDown(Constant.Input.KeyNum03))
            {
                OnSkillClick?.Invoke(3);
            }
            if (GetButtonDown(Constant.Input.KeyNum04))
            {
                OnSkillClick?.Invoke(4);
            }
            if (GetButtonDown(Constant.Input.KeyNum05))
            {
                OnSkillClick?.Invoke(5);
            }
        }
Example #4
0
        //------------------------------------------------------------------------/
        // Methods
        //------------------------------------------------------------------------/
        public void Update()
        {
            switch (type)
            {
            case InputBinding.Type.Key:
            case InputBinding.Type.MouseButton:
            {
                switch (state)
                {
                case InputBinding.State.Down:
                    if (input.isDown)
                    {
                        onInput.Invoke();
                    }
                    break;

                case InputBinding.State.Up:
                    if (input.isUp)
                    {
                        onInput.Invoke();
                    }
                    break;

                case InputBinding.State.Pressed:
                    if (input.isPressed)
                    {
                        onInput.Invoke();
                    }
                    break;
                }
            }
            break;


            case InputBinding.Type.Axis:
                if (!input.isNeutral)
                {
                    onAxisInput.Invoke(input.value);
                }
                break;
            }
        }
 void FixedUpdate()
 {
     OnAxisInput?.Invoke(Input.GetAxisRaw(Horizontal), Input.GetAxisRaw(Vertical));
     OnJumpInput?.Invoke(Input.GetAxisRaw(Jump));
 }