private IEnumerator ListenForKeyToChange(IInputHandler handler, string listenerName, bool positive, Action UIUpdater) { var newKey = KeyCode.None; var listener = handler.GetListener(listenerName); if (listener == null) { yield break; } while (newKey == KeyCode.None) { foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode))) { if (!Input.GetKey(keyCode)) { continue; } newKey = keyCode; break; } yield return(new WaitForEndOfFrame()); } KeyCode oldKey; if (positive) { oldKey = listener.Positive; listener.Positive = newKey; } else { oldKey = listener.Alternative; listener.Alternative = newKey; } if (UIUpdater != null) { UIUpdater.Invoke(); } handler.ChangeKey(listenerName, oldKey, newKey); UpdateStack(); }