Input Icons for Input System - Easily display action bindings

Hello
I just installed the package in my Unity project.
I currently have an AZERTY keyboard, but in the build or in the editor, the key displayed does not correspond to that of my AZERTY keyboard.
Is there a specific setup for changing the keyboard layout?

For example, if I press the Z key on my keyboard, the W key is displayed.

Hi @aberractic
This looks like it could be a bug which might have gotten introduced with one of the latest updates.

I’m already looking into this and it seems there was a caching issue. Will push an update to the asset store once I can confirm the language settings is working as expected. :slight_smile:

Update: I just submitted version 4.0.7 with a fix. The Text Display Language setting in the inspector of the InputIconsManager now works as expected again. You can test the different keyboard layouts by changing the system language to English, French and German for example without needing a separate keyboard device.

Update 2: The new version is now ready and can be downloaded through the package manager.

1 Like

It’s work but not for all

It’s actualy work if my system is in French ( french) but not in French ( belgium ) for example

You are right, good catch! I haven’t tested for that as I expected it to work automatically. Thank you very much for reporting, will investigate this immediately and and check how the input system handles these cases. Looks like for now Input Icons is falling back to the QWERTY layout, which obviously is not ideal.

Update: @aberractic please try replacing your current InputIconsKeyboardProcessor script with this one. I changed the layout detection from checking for Keyboard.current.keyboardLayout to checking for the “a” and “z” keys on the keyboard. This should more reliably display the actual layout now. Sorry for the inconveniences caused and thanks again for bringing this up!
InputIconsKeyboardProcessor.cs (23.8 KB)

It seems to work correctly for the display

On the other hand, if I switch to a QWERTY keyboard layout and rebind some keys, then they are bound to the keys of my AZERTY keyboard.

So if I switch to QWERTY and press the Z key on my AZERTY, it indeed shows the “W” key, but if I press that same key, it doesn’t seem to be bind correctly. it feels like it’s not the physical key that’s bound.

Strange, it does work in my example scenes. For example, I bind my Up/Down/Left/Right keys to 2/W/Q/E on a QWERTY layout. Then change to a AZERTY layout, it displays 2ZAE (digits and special characters falling back to QWERTY). When I press Q/E or A/E, I can move left and right. (Note that the Up/Down bindings don’t do anything in the example scenes)

However, I did not test on an actual physical AZERTY keyboard, only on my QWERTZ keyboard and changing the system language.

If you use a generated C# class (generated from the Input Action Asset), then you will have to additionally update the instance(s) where you use them as the prefab rebind button objects can only rebind the input action directly inside the Input Action Asset. There is a section 4.5.2 in the guide for this. Basically you need to add these lines to the Awake or OnEnable methods where you have your instances of the generated class:

//call these lines to use the overrides managed by the Input Icons Manager
//register for rebind changes
InputIconsManagerSO.RegisterInputActionAssetForRebinding(inputActions.asset);
//sync up already made changes with the instance
InputIconsManagerSO.UpdateRegisteredInputActionAssetsForRebinding(inputActions.asset);

But I could be missing something. Please if you got time, test again with rebinding the Left/Right or the Jump key and see if this works in the example scenes - possibly in a fresh project - and in your custom scenes. If it still does not work, I will try to grab a physical AZERTY keyboard and dive in deeper.

Edit: I attached a short script which could be helpful in testing if the bindings actually update (at least the ones on the Input Action Asset)
LogBinding.cs (250 Bytes)

Hello, I am implementing your asset into my project, and it has been incredible so far! One question I have for control rebinding, how would I go about being able to listen for 4 rebinds in a row for a composite action, such as a move action using keyboard and mouse? For example, when detecting keyboard, the rebind will show WASD all together, and selecting it will prompt the player 4 times for each part of the composite, and then when switching to gamepad, it will only prompt for a single Vector2 joystick. If this has already been answered somewhere in this thread, would someone be able to link me to that? Thank you!!!

Hi @Master_Davicous
Great to hear the asset has suited your needs well so far.
Unfortunately the behavior you describe is not yet available within the asset. I believe what you want is something like this where it shows WASD for the keyboard and a single Vector 2 binding (Left or Right Stick) for the gamepad. You could then rebind all 4 keyboard keys at once in a sequence or rebind the left stick to the right stick or maybe another Vector2 input.

The current rebind prefabs however can only rebind single bindings at a time. A workaround would be to have 5 rebind buttons instead of 2. The WASD rebind buttons always showing the keyboard keys and the left stick always displaying the Gamepad by selecting Gamepad as the Device Type in the inspector.
grafik

Obviously the first solution would be much more elegant. I will see if I can make it work! :slight_smile:

Edit: The update v4.1.0 which includes sequential multi rebinding is now online!

1 Like

Hi,

Regarding the RegisterInputActionAssetForRebinding() method, if I add the following code:

void Awake()
{
    InputIconsManagerSO.RegisterInputActionAssetForRebinding(inputActions.asset);
    InputIconsManagerSO.UpdateRegisteredInputActionAssetsForRebinding(inputActions.asset);

Do I also need to include the following in OnDestroy?

void OnDestroy()
{
    InputIconsManagerSO.UnregisterInputActionAssetForRebinding(inputActions.asset);

The reason I’m asking is that I couldn’t find any reference to UnregisterInputActionAssetForRebinding() in the online manual, and the II_InputActions_ControllerTemplate example doesn’t seem to use this method.

Thanks!

Hi @pmourao

you don’t necessarily need to call

InputIconsManagerSO.UnregisterInputActionAssetForRebinding(inputActions.asset);

again. Once you register an asset, the manager will update the bindings of the asset when you rebind it using the rebind prefabs. You probably don’t want to unregister it at runtime again if you want to keep the rebound bindings in sync.

You can use the unregister method if needed, but it is very unlikely. It exists just in case. :slight_smile:

1 Like

Hi @tobias_froihofer

Thank you very much for the clarification.

I did some further testing and noticed that since I am creating a new instance of my input class (a non-persistent Singleton) in each scene, the subscribedAssetsForRebinding.Count was actually growing with every scene load. Therefore, I think I’ll keep using the unregister method in my specific setup.

Thanks again for the help and for the great asset!

1 Like

Hi, I can’t get optional icon sets to work for multiplayer image prompts. It always uses the configurator set. The sprite does show up in the II_LocalMultiplayerImagePrompt preview, but not in the Image component.
Any ideas?

Hello @Mechano_unity

Thank you for reporting the issue, this is a bug.
Seems the script did not actually check for the optional override icon sets.

Here is a fix: open the II_LocalMultiplayerSpritePrompt.cs file and replace the GetKeySprite method (around line 245) with the following.

public Sprite GetKeySprite()
{
    if (actionReference == null)
        return null;

    InputDevice device = InputIconsManagerSO.localMultiplayerManagement.GetDeviceForPlayer(playerID);
    if (device == null)
    {
        return InputIconSetConfiguratorSO.Instance.keyboardIconSet.unboundData.sprite;
    }

    InputIconSetBasicSO iconSet = InputIconSetConfiguratorSO.GetIconSet(device);

    if (iconSet is InputIconSetKeyboardSO && optionalKeyboardIconSet != null)
        iconSet = optionalKeyboardIconSet;

    if (iconSet is InputIconSetGamepadSO && optionalGamepadIconSet != null)
        iconSet = optionalGamepadIconSet;

    string chosenControlSchemeName = InputIconsManagerSO.localMultiplayerManagement.GetControlSchemeForPlayer(playerID);
    //Debug.Log("chosen control scheme: "+chosenControlSchemeName);
    if (chosenControlSchemeName == "")
    {
        if (iconSet is InputIconSetKeyboardSO)
            chosenControlSchemeName = GetControlSchemeNameKeyboard();
        else
            chosenControlSchemeName = GetControlSchemeNameGamepad();
    }

    string keyName = "";
    if(iconSet is  InputIconSetKeyboardSO)
        keyName = InputIconsUtility.GetSpriteName(actionReference, compositeTypeKeyboard, bindingTypeKeyboard, chosenControlSchemeName, bindingIndexKeyboard);

    if (iconSet is InputIconSetGamepadSO)
        keyName = InputIconsUtility.GetSpriteName(actionReference, compositeTypeGamepad, bindingTypeGamepad, chosenControlSchemeName, bindingIndexGamepad);


    return iconSet.GetSprite(keyName);
}

This should then work for local multiplayer sprite prompts and image prompts as well.
I just saw the local multiplayer text prompt does not have the options for override icon sets yet. Will add it with the next update as soon as I can.

Hi @tobias_froihofer,

I am using the II_UI_RebindActionImageObject prefab for rebinding inputs. Everything works correctly in the Unity Editor .

However, in the build version , the input icon updates correctly after rebinding, but the actual controls do not change and remain the same as before the rebind.

Any idea what could be causing this?

Hi @PeterJurkovsky,

usually Input Icons works out of the box, both in editor and in a build. Maybe something is throwing an error for you in the build when you rebind something? Please check. This is helpful to quickly add logging in play mode: Is there any way to view the console in a build? - #6 by bboysil

Here are some questions which might help me in reproducing the issue.

Which versions the following do you use in your project?

  • Unity
  • Input System
  • Input Icons

Also: Do you use a Generated C# file (from the Input Action Asset) for controls or do you use the actions of the Input Action Asset directly? The II_UI_RebindActionImageObject prefab rebinds the data within the input action assets themselves. If you use a generated C# class, you should look at the “Rebinding Using A Generated C# Class” section of the guide. Somewhere within section 4.5.x. It probably is unrelated, but is worth looking into.

Thank you for fast reply. I have managed to make it work. I am using an Input Action Asset directly in Settings screen where I do rebinding ..but, player (character in scene) uses PlayerInput component and looks like in build it creates a separate instance (?) of Input Action, so I had to manually apply rebinds also to this instance when level starts or when player changes rebinds in Settings screen during level. Not sure if this is a proper way but now it works fine. Thank you!

Glad to hear you fixed it. I think I have a similar setup like you. I use the actions of the Input Action Asset directly in the rebind prefabs and I also have a Player Input component which uses “Invoke Unity Events” as Behavior. So far rebinding worked fine in builds as well. I will keep an eye out for similar issues though. Anyways, thank you for reaching out!

Yes looks like we have similiar setup. I guess the only difference is that my player (with Player Input component) is spawned in different scene.

Input Action Asset is used when game starts in Main Menu and then Player Input component is spawned when Level starts.

Hi @tobias_froihofer ,
I’m using this package for my project, but I only need one set of icon style. How do I safely remove the other icon packs and asset without breaking this? Also is there other optional folders and files that I can remove to reduce bloat in my project?

Hey @smolsignal,

there is a lot you can remove. But you might want to backup your project first. Just in case.

You can check which icon sets you are using by looking at the inspector of the InputIconSetConfigurator within Assets/InputIcony/Resources/InputIcons/ - let’s say you use the default icon set.

In that case you would be using Keyboard_Grey, PS3, PS4, PS, NSwitchPro and XBox.
You could then savely delete/keep the following Icon Sets (just delete the ones, not referenced on the Input Icon Set Configurator).

For the sprites it is the same, just delete what is not referenced on the remaining Icon Sets.
First you can start by deleting either the KeyboardAndGamepadSprites_Vol1 or KeyboardAndGamepadSprites_Vol2 folder. If you use the default prompts like in my example, delete the KeyboardAndGamepadSprites_Vol2 folder.

You can look into the remaining KeyboardAndGamepadSprites_Vol1 + subfolders and only keep the folders with the name Default or Grey.
Delete folders that are named “Flat”, “Fontstyle” within the Gamepad subfolders and delete the folders under KeyboardAndMouse and only keep Grey.

Here is a screenshot of what you can keep/remove if you are using the default prompts.

Let me know if you have any further questions. :slight_smile: