private void OnPlayerInputChanged(InputListener inputListener) { PlayerControlInfo playerControlInfos = inputListener.m_Player == EPlayer.Player1 ? m_Player1ControlsMapping : m_Player2ControlsMapping; List <EInputKey> unassignedInputs = new List <EInputKey>(PlayerGamePad.K_ASSIGNABLE_INPUTS); for (int i = 0; i < playerControlInfos.m_InputListeners.Length; i++) { if (playerControlInfos.m_InputListeners[i] != inputListener && playerControlInfos.m_InputListeners[i].m_CurrentInputKey == inputListener.m_CurrentInputKey) { EGamePadType playerGamepadType = GamePadManager.GetPlayerGamepadType((int)inputListener.m_Player); playerControlInfos.m_InputListeners[i].m_CurrentInputKey = inputListener.m_OldInputKey; playerControlInfos.m_InputListeners[i].UpdateInputForGamepadType(playerGamepadType); GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, inputListener.m_OldInputKey, playerControlInfos.m_InputListeners[i].m_DefaultInputKey); } unassignedInputs.Remove(playerControlInfos.m_InputListeners[i].m_CurrentInputKey); } #if UNITY_EDITOR || DEBUG_DISPLAY if (unassignedInputs.Count > 1) { KakutoDebug.LogError("There should be only one unassigned remaining input after OnPlayerInputChanged"); } #endif for (int i = 0; i < unassignedInputs.Count; i++) { GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, unassignedInputs[i], PlayerGamePad.K_DEFAULT_UNASSIGNED_INPUT); } }
private void StopListeningInput() { UpdateInputSprite(); GamePadManager.SetPlayerGamepadInputMapping((int)m_Player, m_CurrentInputKey, m_DefaultInputKey); m_CurrentEventSystem.enabled = true; bool isXboxGamepad = GamePadManager.GetPlayerGamepadType((int)m_Player) == EGamePadType.Xbox; m_XboxImageInput.enabled = isXboxGamepad; m_PS4ImageInput.enabled = !isXboxGamepad; m_PressAKeyText.enabled = false; m_InputButton.Select(); m_IsListeningInput = false; OnInputChanged?.Invoke(this); }
protected void OnEnable() { for (int i = 0; i < m_OptionButtons.Length; i++) { Navigation buttonNavigation = m_OptionButtons[i].navigation; buttonNavigation.selectOnDown = m_DefaultSelectable; m_OptionButtons[i].navigation = buttonNavigation; } UpdateHighlightedGameObject(m_ControlsHighlightInfo); EGamePadType playerGamepadType = GamePadManager.GetPlayerGamepadType((int)EPlayer.Player1, OnPlayer1GamepadTypeChanged); UpdateInputForGamepadType(playerGamepadType, m_Player1ControlsMapping); playerGamepadType = GamePadManager.GetPlayerGamepadType((int)EPlayer.Player2, OnPlayer2GamepadTypeChanged); UpdateInputForGamepadType(playerGamepadType, m_Player2ControlsMapping); }