@Rene-Damm to follow up, newest update to the input system and it’s prefabs (.7 preview) does not resolve the issue
Yeah still having the same issue. I also tried the code suggested to set the binding group but the new control still doesn’t work and the old one does. Is there an ETA on this fix? This feature request has been blocked in my game since January because of this…
GENTLEMEN, WHERE I WAS TOO DUMB TO UNDERSTAND BEFORE, NO MOOORE!
@Rene-Damm actually gave me the solution and i didn’t realize it.
Here is a sample of what I had been using. My input action was named NewControls so I had built this into each script that needed to hear player input. This was utilizing the C# Generated Wrapper that Rene was talking about. I also had a PlayerInput component on my game object that was set to call C# events.
This was wrong.
Solution:
In order to make the RebindActionUI prefab function, I had to set the PlayerInput component to call Unity Events, and then manually link the events. I had to remove everything in the red box above as well as the “NewControls.IShooterActions” from the top line in the picture above. Then I left all of my OnMove/OnShoot/OnSubmit/etc. methods in my script and instead of the wrapper (variable “controls” in the picture above) calling them, i manually linked them to the unity events in the PlayerInput component in the inspector.
After that, my keybindings started to fall into place. The other gotcha I ran into was that my “Input System UI Input Module” component with the EventSystem had been using actions from the same action map that I had setup rebinding elements for. This rendered them as “enabled” even when the PlayerInput module was disabled. If you have an action map for “In Game Events” then you’ll want another action map for “UI Interactions” and have those actions in the “Input System UI Input Module”. So you can disable your PlayerInput component as you enter the rebinding menu, use the “UI Interactions” action map to continue to navigate around and interact with the rebinding ui, and then re-enable your PlayerInput component as you exit the rebinding menu.
@ZachariBarnes @ItsTwelveOclock @bilbaeno hope any of that helps you
Thanks I’ll try this out sometime this week I hope!
Was this ever resolved? I tried using the Rebinding UI example and prefab, and while it does update the new binding in the UI, it does not actually rebind (at runtime). I couldn’t follow Ghosts proposed solution at all. Has anyone gotten the Rebinding UI example/prefab to actually rebind at runtime?
Video is Renee showing the example and prefab that I’m referring to:
How are you attaching a PlayerInput component or C# class to your object?
I did precisely what the video suggests, which is take the prefab he built and the scripts he included, and simply reconnect it to my Player Controls (and yes I override the prefab to my values).
The button itself uses his script to actually perform the binding.
It does work, in the same sense that his example works, I see it update the UI with the new key for rebinding, however it does not change the underlying controls. Note: his provided scene ALSO doesn’t seem to update his controls, it literally only changes the UI. It seems very bizarre to me to release an official sample called Rebinding Sample that doesn’t actually rebind (even at runtime)?
It’s using entirely his code, nothing custom. The only thing “custom” is the references themselves to my player controls via the inspector.
I had the same issue, and this video
given me the hint to solution. Manuals I have seen before used the following approach: after you created PlayerControls asset, you used it to generate C# class, and created scripts like
public PlayerControls controls;
…
controls = new PlayerControls();
controls.Input.Interact.performed += ctx => Interact();
The thing is: you do not need it now. What you do need, is to add to the game object (where you controls should be) component called “Player Input”. In it, you must setup Actions and Default Map (which should be the same as on the buttons you using to change keybindings).
When you can select behaviour. If you using “Send messages”, it will show you list of messages this component generates based on you input, and all you have to do, is to create in a script attached to the same gameoject method with the same name as in the list. For example, I have action called “Interact” and I see that among the messages list there is “OnInteract”. So I just create in the script following method:
public void OnInteract()
{
Debug.Log(“Interacting”);
}
Last, but not least: you have to disable action map before you can rebind it. In my experimental project, I am using following code (attached to a three buttons on UI) for manually turn it on or off:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class ToogleInput : MonoBehaviour
{
public PlayerInput playerController;
private InputActionMap actionMap;
// Start is called before the first frame update
void Start()
{
actionMap = playerController.actions.FindActionMap(“Input”);
}
public void On()
{
actionMap.Enable();
Check();
}
public void Off()
{
actionMap.Disable();
Check();
}
public void Check()
{
if (actionMap.enabled) { Debug.Log(" action map enabled"); }
else { Debug.Log(" action map disabled"); }
}
}
Of course in real project you have to do it automatically (and do checks for assignments etc.).
To update On this I have attempted all the things explained in the above posts, I have added the player Input component and attempted a rebind. It failed due to the action map being enabled so I added an enable and disable to the Interactive rebind. Code to follow
public void StartInteractiveRebind()
{
if (!ResolveActionAndBinding(out var action, out var bindingIndex))
return;
action.actionMap.Disable();
// If the binding is a composite, we need to rebind each part in turn.
if (action.bindings[bindingIndex].isComposite)
{
var firstPartIndex = bindingIndex + 1;
if (firstPartIndex < action.bindings.Count && action.bindings[firstPartIndex].isPartOfComposite)
PerformInteractiveRebind(action, firstPartIndex, allCompositeParts: true);
}
else
{
PerformInteractiveRebind(action, bindingIndex);
}
action.actionMap.Enable();
}
However once again this only updates the UI to display the new key but the game does not respond to the input at all. I really don’t think it can be said better than this:
@Rene-Damm is there any update on this at all? This Issue has been open since Feb 15. It’ll be 6 months in 10 days…
@GhostStreetGuru did you ever get this resolved in your experiments?
As I’m trying to get an Input rebinder to work for my game, I ended up doing everything mentioned in the previous posts with no luck.
Only useful thing I could add is that both with or without enabling/disabling the actions and action map on rebind, this is what the Input Debug window shows me:
Before doing any rebinding
After having rebound an action called “Jump”.
A new action with the same name seems to have been created?
This third “Jump” action is correctly rebound to the button I pressed (“enter” in this case). As all of you reported so far, the UI also correctly shows the new input binding (which, again, is the “enter” key).
I’m not particularly expert of the Input Debugger, but the apparent creation of a new action instead of modifying the existing ones could be a good lead to understand what’s wrong?
Btw, in case anyone wonders, the actions being doubled by default should be unrelated to this input rebinding matter: a second copy of each action appears the moment the Input Action Asset of choice gets enabled. I can also add that no additional copies of the actions get created if you were to Enable() it multiple times, nor if you happen to both call Enable() and Disable() back and forth at any point.
Addendum:
If I keep rebinding this jump action, no more copies of the action get created, but instead this “third instance” of the action just keeps changing according to what I’m pressing.
Effectively, the “third instance” always shows exactly what is shown in the UI.
The more I keep inspecting this, the more likely it seems that this a good element to check.
Was anyone able to get this working?
I did some testing and changing the binding directly from the InputActions works as expected, but doesn’t work when using InputActionReference as used in the Input System rebinding example.
No I still have a non-functioning input binder in my game. At this rate it looks I’m shipping without the ability to rebind keys.
I wish I was more active on this forum so I would know who to ping for help. @Rene-Damm hasn’t responded to this thread in many months.
I found a solution, but it’s not pretty.
controls is the class I create the InputActions in. You have to make sure, you use the same InputActions you use for the input controls in the game.
foreach (var map in controls.inputs.asset.actionMaps)
{
foreach (var tempAction in map.actions)
{
if (tempAction.name == m_Action.action.name)
{
inputAction = tempAction;
break;
}
}
if (inputAction != null)
{
break;
}
}
@
That’s great, Where are you running this code? In the rebind action?
Also are you using a Player Input component?
Thanks
Yes in rebind action.
No, I just create an object of InputActions.
How did you import your class into the RebindActionUI
class? Whenever I try I get a “Type or Namespace name could not be found” Error and it wont compile. @
Also What are you doing with the inputaction and where does it come from?
Can you show all the code for the method it is in? I think that would help me.
Hi,
do you guys still have this issue. I am able to change/save/load overrides but the new overridden bindings are not respected. Still getting input only from bindings set in the editor. I am using latest InputSystem v1.0.1.0
Is this still broken !?
Has anyone got this working? Id happily pay a couple quid on the asset store for basic character controller example that can open a ui and rebind the actions. Bonus points for a Disco theme.
@Vagabond @pantang_1
I have not gotten this working yet. I am shipping by game next month so I’m just sending it without the ability to rebind keys. I too would love to see a working version of this. Right now this whole experience has left a really bad taste in my mouth. The fact this thread has been continuously ignored by the Unity Team makes me feel like they routinely ship broken features and don’t really care about the people who use them. I switched to the new input system because I was told the old one would not allow for rebinding keys, In reality it seems like Unity does not allow rebinding keys at all out of the box and you have to build your own input system if you want this functionality. I’m extremely grateful for everyone who tried to help fix this problem but unfortunately I’ve given up hope on finding an answer here. Maybe We should try Stack Overflow or look for an existing asset on the store for this feature.