I want to get a specific bind from this 2D composite (or any specific input in an action that has multiple).
In the method shown below, I use the path to an action to rebind it, so, if I have an action with one bind in it, I simply type the name of the action and I can rebind it. But for 2D composites or multiple binds in a single action, this doesn’t simply happen as it changes ALL the binds in it.
Two photos below**
So far I tried stuff like: “Movement/2DVector/Up” and similar pathing which didn’t work. I tried the following method but it kept returning /a which is obviously useless.
[Button] public void FindPath(int index)
Debug.Log("effecting path is: " +inputAction.bindings[index].effectivePath);
Debug.Log("path is: " +inputAction.bindings[index].path);
So I need to get the specific “path” if that even exists, otherwise, how do I deal with this?
Okay, I have figured out the answer. It is as simple as passing in the int index of the binding in the composite in the PerformInteractRebinding(int index). method
Here’s how: each binding inside the composite has its own binding, in order STARTING with W, it’s 1, up until 8.
Then you pass in that index wherever your code is, or in my case, it is first assigned in the inspector, then passed to the method
After that, just put that int index in the PerformInteractRebinding(int index) method.
Note: I know this is in no way a necessarily great solution or that anyone should use it, I just made it because I wanted to create the rebinding from scratch to train on coding. For the people that don’t care about making it from scratch, I suggest just importing the UI Button Binding asset from the asset manager. It is way more versatile than this, and even allows you to put icons instead of just texts.