using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class InputManagerScript : MonoBehaviour { // Input Options [Header("Input")] [SerializeField] private KeyCode moveRight; [SerializeField] private KeyCode moveLeft; [SerializeField] private KeyCode moveForward; [SerializeField] private KeyCode moveBack; [SerializeField] private KeyCode jump; [SerializeField] private KeyCode shoot; [SerializeField] private KeyCode reload; // for the UI of button remaping [SerializeField] private TextMeshProUGUI[] currentKeys; // Update is called once per frame void Update() { } //---------------------------------------- Get Input (for other Scripts) ----------------------------------------- public KeyCode getMoveRight() { return moveRight; } public KeyCode getMoveLeft() { return moveLeft; } public KeyCode getMoveForward() { return moveForward; } public KeyCode getMoveBack() { return moveBack; } public KeyCode getJump() { return jump; } public KeyCode getShoot() { return shoot; } public KeyCode getReload() { return reload; } //---------------------------------------------- Remap Buttons ---------------------------------------------------- public void remapKey(string actionName, KeyCode key) // remaps the action to the new Button and changes it in the UI (keybinding) { switch(actionName) { case "moveRight": moveRight = key; // new Button currentKeys[0].text = key.ToString(); break; case "moveLeft": moveLeft = key; currentKeys[1].text = key.ToString(); break; case "moveForward": moveForward = key; currentKeys[2].text = key.ToString(); break; case "moveBack": moveBack = key; currentKeys[3].text = key.ToString(); break; case "jump": jump = key; currentKeys[4].text = key.ToString(); break; case "shoot": shoot = key; currentKeys[5].text = key.ToString(); break; case "reload": reload = key; currentKeys[6].text = key.ToString(); break; } } }