111 lines
2.7 KiB
C#
111 lines
2.7 KiB
C#
using UnityEngine;
|
|
|
|
public class KeyBindManager : MonoBehaviour
|
|
{
|
|
public Transform containerSlot;
|
|
|
|
public GameObject slotPrefab;
|
|
|
|
[HideInInspector]
|
|
public InputManager inputManager;
|
|
|
|
public bool isSelect;
|
|
|
|
private void OnEnable()
|
|
{
|
|
ShowContent();
|
|
}
|
|
|
|
private void ShowContent()
|
|
{
|
|
inputManager = Object.FindObjectOfType<InputManager>();
|
|
GameManager.TruncateContainer(containerSlot);
|
|
for (int i = 0; i < inputManager.keysbind.Count; i++)
|
|
{
|
|
KeyBindListItem component = Object.Instantiate(slotPrefab, containerSlot).GetComponent<KeyBindListItem>();
|
|
component.keycode = inputManager.keysbind[i].key;
|
|
component.DescText.text = LanguageManager.Instance.GetText(inputManager.keysbind[i].DesciptionLangKey.ToUpper());
|
|
component.indexOfKey = i;
|
|
component.keyBindManager = this;
|
|
}
|
|
}
|
|
|
|
public void RestoreDefualt()
|
|
{
|
|
for (int i = 0; i < inputManager.keysbind.Count; i++)
|
|
{
|
|
inputManager.keysbind[i].key = inputManager.keysbind[i].defaultkey;
|
|
}
|
|
ShowContent();
|
|
}
|
|
|
|
public string ConvertKeyToString(KeyCode key)
|
|
{
|
|
return key switch
|
|
{
|
|
KeyCode.Keypad0 => "NUM 0",
|
|
KeyCode.Alpha0 => "0",
|
|
KeyCode.Keypad1 => "NUM 1",
|
|
KeyCode.Alpha1 => "1",
|
|
KeyCode.Keypad2 => "NUM 2",
|
|
KeyCode.Alpha2 => "2",
|
|
KeyCode.Keypad3 => "NUM 3",
|
|
KeyCode.Alpha3 => "3",
|
|
KeyCode.Keypad4 => "NUM 4",
|
|
KeyCode.Alpha4 => "4",
|
|
KeyCode.Keypad5 => "NUM 5",
|
|
KeyCode.Quote => "'",
|
|
KeyCode.Alpha5 => "5",
|
|
KeyCode.Keypad6 => "NUM 6",
|
|
KeyCode.Alpha6 => "6",
|
|
KeyCode.Keypad7 => "NUM 7",
|
|
KeyCode.Alpha7 => "7",
|
|
KeyCode.Keypad8 => "NUM 8",
|
|
KeyCode.Alpha8 => "8",
|
|
KeyCode.Keypad9 => "NUM 9",
|
|
KeyCode.Alpha9 => "9",
|
|
KeyCode.LeftControl => "LCTRL",
|
|
KeyCode.RightControl => "RCTRL",
|
|
KeyCode.LeftShift => "LSHIFT",
|
|
KeyCode.RightShift => "RSHIFT",
|
|
KeyCode.LeftAlt => "LALT",
|
|
KeyCode.RightAlt => "RALT",
|
|
KeyCode.DownArrow => "DOWN",
|
|
KeyCode.LeftArrow => "LEFT",
|
|
KeyCode.RightArrow => "RIGHT",
|
|
KeyCode.UpArrow => "UP",
|
|
KeyCode.PageUp => "PGUP",
|
|
KeyCode.Tab => "Tab",
|
|
KeyCode.PageDown => "PGDN",
|
|
KeyCode.KeypadMinus => "NUM -",
|
|
KeyCode.Minus => "-",
|
|
KeyCode.Equals => "=",
|
|
KeyCode.KeypadPlus => "NUM +",
|
|
KeyCode.Slash => "/",
|
|
KeyCode.Backslash => "\\",
|
|
KeyCode.Backspace => "BACK",
|
|
KeyCode.Period => ".",
|
|
KeyCode.Comma => ",",
|
|
KeyCode.Numlock => "NUM",
|
|
KeyCode.CapsLock => "CAPS",
|
|
KeyCode.Mouse0 => "LMB",
|
|
KeyCode.Mouse1 => "RMB",
|
|
KeyCode.RightBracket => "]",
|
|
KeyCode.LeftBracket => "[",
|
|
KeyCode.KeypadDivide => "NUM /",
|
|
KeyCode.KeypadPeriod => "NUM .",
|
|
KeyCode.KeypadEnter => "NUM ENTER",
|
|
KeyCode.KeypadMultiply => "NUM *",
|
|
_ => key.ToString(),
|
|
};
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
}
|