public IEnumerator ChangeKeybind(KeyAction selectedAction, bool isPrimary) { KeyValuePair <KeyAction, KeybindObject> conflictingKVP; KeyCombo capturedKeyCombo = KeyCombo.None; bool isConflictPrimary = true; // Wait for the keycombo to be captured KeyCapturePanel.SetActive(true); UIManager.IsInputFocus = true; while (capturedKeyCombo == KeyCombo.None) { capturedKeyCombo = keybindManager.CaptureKeyCombo(); yield return(null); } KeyCapturePanel.SetActive(false); // If null stop the function (null is returned if Escape was captured) if (capturedKeyCombo == null) { Logger.Log("Captured Escape key, cancelling change", Category.Keybindings); UIManager.IsInputFocus = false; yield break; } Logger.Log("Captured key combo: " + capturedKeyCombo.ToString(), Category.Keybindings); conflictingKVP = tempKeybinds.CheckConflict(capturedKeyCombo, ref isConflictPrimary); KeyAction conflictingAction = conflictingKVP.Key; KeybindObject conflictingKeybindObject = conflictingKVP.Value; if (conflictingAction == KeyAction.None) { // No conflicts found so set the new keybind and refresh the view tempKeybinds.Set(selectedAction, capturedKeyCombo, isPrimary); // Make sure the player can move around again UIManager.IsInputFocus = false; PopulateKeybindScrollView(); } // Check that the conflict isn't with itself, if it is just ignore it else if (conflictingAction != selectedAction) { // Check if the user wants to change the keybind modalPanelManager.Confirm( "Warning!\n\nThis combination is already being used by:\n" + conflictingKeybindObject.Name + "\nAre you sure you want to override it?", () => { // User confirms they want to change the keybind tempKeybinds.Set(selectedAction, capturedKeyCombo, isPrimary); tempKeybinds.Remove(conflictingAction, isConflictPrimary); UIManager.IsInputFocus = false; PopulateKeybindScrollView(); }, "Yes", () => { UIManager.IsInputFocus = false; } ); } }