private bool AllowMoveEventProcessing(float time) { bool allow = false; for (int i = 0; i < players.Length; i++) { Rewired.Player player = players[i]; if (player == null) { continue; } allow |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); allow |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); allow |= (time > m_NextAction); } return(allow); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } bool shouldActivate = false; // Combine input for all players for (int i = 0; i < players.Length; i++) { Rewired.Player player = players[i]; if (player == null) { continue; } shouldActivate |= player.GetButtonDown(m_SubmitButton); shouldActivate |= player.GetButtonDown(m_CancelButton); if (moveOneElementPerAxisPress) // axis press moves only to the next UI element with each press { shouldActivate |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); shouldActivate |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); } else // default behavior - axis press scrolls quickly through UI elements { shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_VerticalAxis), 0.0f); } } shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= mouse.GetButtonDown(0); return(shouldActivate); }
private Vector2 GetRawMoveVector() { Vector2 move = Vector2.zero; bool horizButton = false; bool vertButton = false; // Combine inputs of all Players for (int i = 0; i < players.Length; i++) { Rewired.Player player = players[i]; if (player == null) { continue; } if (moveOneElementPerAxisPress) // axis press moves only to the next UI element with each press { float x = 0.0f; if (player.GetButtonDown(m_HorizontalAxis)) { x = 1.0f; } else if (player.GetNegativeButtonDown(m_HorizontalAxis)) { x = -1.0f; } float y = 0.0f; if (player.GetButtonDown(m_VerticalAxis)) { y = 1.0f; } else if (player.GetNegativeButtonDown(m_VerticalAxis)) { y = -1.0f; } move.x += x; move.y += y; } else // default behavior - axis press scrolls quickly through UI elements { move.x += player.GetAxisRaw(m_HorizontalAxis); move.y += player.GetAxisRaw(m_VerticalAxis); } horizButton |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); vertButton |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); } if (horizButton) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (vertButton) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }