Пример #1
0
 public void OnComplete(InputActionRebindingExtensions.RebindingOperation operation)
 {
     Debug.Log(InputActionRebindingExtensions.GetBindingDisplayString(operation.action));
     //control = operation.selectedControl;
     txtControl.text = Global.instance.ReplaceWithControlNames("[" + operation.action.name + "]");
     //txtControl.text = InputControlPath.ToHumanReadableString( operation.selectedControl.path );
     //txtControl.text = operation.action.GetBindingDisplayString( InputBinding.DisplayStringOptions.DontUseShortDisplayNames );
 }
 public void StartRebind(ControlBindingItem cbi)
 {
     //if( cbi.action.controls.Count == 0 )
     Global.instance.Controls.Disable();
     cbi.button.interactable = false;
     InputActionRebindingExtensions.PerformInteractiveRebinding(cbi.action)
     //.OnCancel( OnCancel )
     .OnComplete((x) => {
         cbi.OnComplete(x);
         cbi.button.interactable = true;
         EventSystem.current.SetSelectedGameObject(cbi.button.gameObject);
         Global.instance.Controls.Enable();
     })
     .OnMatchWaitForAnother(0.2f)
     .Start();
 }
Пример #3
0
    }//RebindKey

    /*
     * Rebind Complete
     * Toggles off blocker, deletes rebinder from memory
     */
    public void RebindComplete(int actionIndex, string lastEffectivePath)
    {
        //Specific to Controls UI
        rebindBlock.SetActive(false);

        //From DapperDino Tutorial
        _rebindingOperation.Dispose();

        InputAction actedInput = _displayKeys.ActionsArrayLocation(actionIndex);
        int         boundInput = _displayKeys.BindingsArrayLocation(actionIndex);

        //Loop to search for duplicate effective paths
        for (int i = 0; i < _rebindsLength; i++)
        {
            if (i != actionIndex)
            {
                if (actedInput.bindings[boundInput].effectivePath ==
                    _displayKeys.ActionsArrayLocation(i).
                    bindings[_displayKeys.BindingsArrayLocation(i)].effectivePath)
                {
                    //If one is found, the new binding reverts to the last effective path.
                    InputActionRebindingExtensions.ApplyBindingOverride(actedInput, boundInput, lastEffectivePath);

                    //The button that already had that effective path turns red, via becoming selected.
                    EventSystem _eventSystem = EventSystem.current;
                    _eventSystem.SetSelectedGameObject(rebindButtons[i].gameObject);

                    //Loop breaks here as there ideally can't be more than one duplicate
                    break;
                }
            }
        }

        //This deletes any "overrides" that are identical to the default path
        if (actedInput.bindings[boundInput].path == actedInput.bindings[boundInput].overridePath)
        {
            ResetKey(actionIndex);
        }
        else
        {
            _displayKeys.SaveKeys();
            UpdateStrings();
            UpdateText();
        }
    }//RebindComplete
Пример #4
0
    }//FlipResetButtons

    /*
     * Reset Key
     * Removes overrides from specific key
     */
    public void ResetKey(int actionIndex)
    {
        //Specific to Controls UI
        InputAction actedInput = _displayKeys.ActionsArrayLocation(actionIndex);
        int         boundInput = _displayKeys.BindingsArrayLocation(actionIndex);

        string lastEffectivePath = actedInput.bindings[boundInput].effectivePath;

        actedInput.RemoveBindingOverride(boundInput);

        //Loop to search for duplicate effective paths
        for (int i = 0; i < _rebindsLength; i++)
        {
            if (i != actionIndex)
            {
                if (actedInput.bindings[boundInput].effectivePath ==
                    _displayKeys.ActionsArrayLocation(i).
                    bindings[_displayKeys.BindingsArrayLocation(i)].effectivePath)
                {
                    //If one is found, the new binding reverts to the last effective path.
                    InputActionRebindingExtensions.ApplyBindingOverride(actedInput, boundInput, lastEffectivePath);

                    //The button that already had that effective path turns red, via becoming selected.
                    EventSystem _eventSystem = EventSystem.current;
                    _eventSystem.SetSelectedGameObject(rebindButtons[i].gameObject);

                    //Loop breaks here as there ideally can't be more than one duplicate
                    break;
                }
            }
        }

        _displayKeys.SaveKeys();
        UpdateStrings();
        UpdateText();
    }//ResetKey
 void RemoveAllBindingOverrides()
 {
     InputActionRebindingExtensions.RemoveAllBindingOverrides(playerInput.currentActionMap);
 }
Пример #6
0
 public void ResetBinding()
 {
     InputActionRebindingExtensions.RemoveAllBindingOverrides(focusedInputAction);
     UpdateBindingDisplayUI();
 }