private void PlayerUpdate() { HotkeyData.Hotkey hotkey = IsUsingHotkey(); if (hotkey != null) { // If hotkey is for OpenDebugMenu if (hotkey.name == "OpenDebugMenu") { return; } DebugManager.LogToFile("Hotkey '" + hotkey.name + "' triggered from pressing '" + hotkey.key.ToString() + "'!", LogType.Log, false, false); if (textAnimation != null) { StopCoroutine(textAnimation); Destroy(textObj); } textAnimation = commandHandler.StartCoroutine(ShowText(hotkey.name, hotkey.key.ToString())); // Start animation of showing text EventListener.OnSceneUnload += OnSceneUnload; // If command is active if (commandHandler.IsCommandActive(hotkey.commandToRun)) { // Deactivate command commandHandler.DeactivateCommand(hotkey.commandToRun); } // If command inactive else { // Activate command commandHandler.ActivateCommand(hotkey.commandToRun, hotkey.commandArgs); } } }
public HotkeyData.Hotkey GetHotkey(string name) { // Iterate through all hotkeys for (int i = 0; i < hotkeyHolder.hotkeys.Count; i++) { HotkeyData.Hotkey hotkey = hotkeyHolder.hotkeys[i]; // If found wanted hotkey, return it if (StringHelper.DoStringsMatch(name, hotkey.name)) { return(hotkey); } } return(null); }
private HotkeyData.Hotkey IsUsingHotkey() { // If any key is pressed if (Input.anyKeyDown) { // Iterate through all hotkeys for (int i = 0; i < hotkeyHolder.hotkeys.Count; i++) { HotkeyData.Hotkey hotkey = hotkeyHolder.hotkeys[i]; // If hotkey is pressed if (Input.GetKeyDown(hotkey.key)) { return(hotkey); } } } return(null); }