Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Current Control Scheme

Discussion in 'Input System' started by Dywindel, Mar 23, 2022.

  1. Dywindel

    Dywindel

    Joined:
    May 17, 2019
    Posts:
    3
    Hi,

    I've setup a control scheme in C# that works fine, using the Input System for Unity. It uses the context commands to check when certain actions are performed and stores the relevent bool/vector2's. I made it using this tutorial from Brackeys.

    How do I add to this system so I can read the current control scheme? I have two control schemes and one action map. Each action in the action map has multiple inputs with the correctly labelled Gamepad or Keyboard controls.

    I'm posting here because I cannot find any results that explain how to read the current control scheme. I see lots of links to this page, but I don't understand how to use that information with my game.
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    There's a sample in the package called "In-Game Hints" which may be useful here. This and that.
     
  3. SergiRegi

    SergiRegi

    Joined:
    Apr 11, 2016
    Posts:
    10
    HI I have similar problem with the input system rebinding with currentcontrolscheme.
    I want to get the bindings or binding of action that corresponds to currentControlScheme.
    For example:
    For Move action, I have composite bindng WASD for keyboard, and Stick Left binding for Gamepad.
    There is a way to form an action make a filter of the bindings that match the currectControlScheme?
    I have revised the samples of Rebinding UI and In. GameHits and I try to understand it, but i can't get it.
    There is a method that I miss or a functionality that I don't know.
    How can I achieve it?
    Thanks
    Sergi
     
    Last edited: Mar 28, 2022
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Get display string for specific control scheme.

    Code (CSharp):
    1. action.GetBindingDisplayString(group: "Gamepad");
    Get index of binding for specific control scheme.

    Code (CSharp):
    1. action.GetBindingIndex(group: "Gamepad");
     
    emredesu likes this.
  5. SergiRegi

    SergiRegi

    Joined:
    Apr 11, 2016
    Posts:
    10
    Yes but when I do the :
    Code (CSharp):
    1. action.GetBindingDisplayString(group:"Keyboard");
    If the action has a IsComposite binding for the Keyboard schema it returns empty string.
    This is normal or you need to impove or fix it to show all parts of composite?
     
  6. SergiRegi

    SergiRegi

    Joined:
    Apr 11, 2016
    Posts:
    10
    Because
    I want to know if a bindind in a bindings array that it has isComposite flag = true if there are any way to know
    to which current schema belows ? or only has the currentSchema the bindings with IsPartComposite:true?
     
    Last edited: Apr 15, 2022