public void Setup(string _toMap) { bindingToMap = _toMap; // Automatically set the onclick function and change the name text to the binding. button.onClick.AddListener(OnClick); bindingName.text = _toMap; // Update the button text with the binding's value and make the GO active BindingUtils.UpdateTextWithBinding(bindingToMap, buttonText); gameObject.SetActive(true); }
private void Update() { if (isRebinding) { KeyCode pressed = BindingUtils.GetAnyPressedKey(); if (pressed != KeyCode.None) { BindingManager.Rebind(bindingToMap, pressed); BindingUtils.UpdateTextWithBinding(bindingToMap, buttonText); isRebinding = false; } } }
// Update is called once per frame void Update() { // Are we rebinding the key? if (isRebinding) { // Try to get any key in the input and check if it was sucessful KeyCode pressed = BindingUtils.GetAnyPressedKey(); if (pressed != KeyCode.None) { // Rebind the key and update the button text BindingManager.Rebind(bindingToMap, pressed); BindingUtils.UpdateTextWithBinding(bindingToMap, buttonText); // Reset the isRebinding flag as we have now rebound the key isRebinding = false; } } }