void Start() { Instance = this; // find the button objects buttons = GetComponentsInChildren <OptionsMenuItem>(); // start with the menu disabled} gameObject.SetActive(false); selectorLocalPos = selector.transform.localPosition; }
IEnumerator AssignKey(InputType keyType, TextMeshProUGUI codeText) { waitingForKey = true; PopupManager.Instance.ShowInputControlMessage(); yield return(WaitForKey()); PopupManager.Instance.HideInputControlMessage(); if (!IsKeyCodeInForbiddenList()) { if (inputInfo.keyInputDict[keyType].inputCode == newKey) { PopupManager.Instance.ShowStandartPopup("You cannot change same key"); } else if (IsSwapRequire()) { SwapKeys(); OptionsMenuController.ChangeInputText(keyType, inputInfo.keyInputDict[keyType].inputCode); OptionsMenuController.ChangeInputText(swapType, inputInfo.keyInputDict[swapType].inputCode); SaveManager.Save(inputData, INPUT_SAVE_FILE_NAME); } else { inputInfo.keyInputDict[keyType].inputCode = newKey; codeText.text = newKey.ToString(); SaveManager.Save(inputData, INPUT_SAVE_FILE_NAME); } } else { PopupManager.Instance.ShowStandartPopup($"{newKey} is a Forbidden Key Change, Try Another Key."); } bool IsKeyCodeInForbiddenList() { return(forbiddenKeyChange.Contains(newKey)); } bool IsSwapRequire() { foreach (var input in inputInfo.keyInputDict) { if (input.Value.inputCode == newKey) { swapType = input.Key; return(true); } } return(false); } void SwapKeys() { inputInfo.keyInputDict[keyType].inputCode = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode; inputInfo.keyInputDict[swapType].inputCode = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode; inputInfo.keyInputDict[keyType].inputCode = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode; } }
private void Awake() { menu = GetComponentInChildren <OptionsMenuController>(); }