I see that in the generated class from the inputactions asset, there is no list of Action Maps (like player or menu) nor a list of actions for each of them.
Should I edit the generated class to add those or would it be possible to generate this automatically?
I’m actually trying to write a tool that’ll generate a key rebind screen as it’s something that is sorely and too often mised in games.
Mmh, issue is this all depends on the generated class, could it be possible to do something like that? Feeding any InputActions asset and get a rebind screen? Even with reflection of some sort? You can’t access the asset directly apart from the asset field in the generated class?
I see that the generated class for the Input asset implements IInputActionCollection which is an IEnumerable but we can’t for-each it…
I’m at a loss, there really isn’t any simple way to go through the different bindings?
Why such a convoluted way of doing this, there are way too many games that don’t bother with keyrebinds (or half ass it), and Unity does not offer an alternative to what they removed.
I’m not sure I understand the problem, the map can be foreached:
I’m using the Rebinding UI sample from the Package Manager. Select the InputAction asset and generate the C# class too.
using UnityEngine;
public class RebindForeach : MonoBehaviour
{
void Start()
{
var map = new RebindUISampleActions();
foreach (var action in map)
{
Debug.Log(action.name);
}
}
}
“Rebinding UI sample from the Package Manager”? I don’t have this one available.
As for the issue, I want to make a tool that generates a rebind screen starting from an input asset and for starter I need to go through the actions of each map. Can we do that starting from an input asset or do we HAVE to use the generated class?
using UnityEngine;
using UnityEngine.InputSystem;
public class RebindForeach : MonoBehaviour
{
[SerializeField] InputActionAsset actionAsset;
void Start()
{
foreach (var action in actionAsset)
{
Debug.Log(action.name);
}
}
}
Probably you can filter out the maps too if you want to. Check the documentation.
Look, it took me 20 minutes or so to get here. When I read your problem I had no idea what the Input System can do. I’m pretty sure if you spend a little bit more time with the documentation and try things out for yourself you can solve whatever problem you have.
So actually this system is super simple and powerful.
You seem to be pretty capable, read this then: once one have all the data for the maps and their actions (which seems pretty nasty to do but whatever) how would one make a tool that’d allow to right click on the Input ASSET and generate a UI panel with all the maps and action?
The detail can be worked out but starting from the input asset, how one would do it?
Then, the imported package contains a Prefab “RebindUIPrefab”.
That Prefab is for one action rebinding. If you make a UI panel which can contain a list of these like a scroll or whatever, you just instantiate a bunch of those Prefabs and set the “action” property to the action value in the foreach in our above examples.
Why do you think I post here if not to get help “solving my own problems”.
Go away now.
As for the decent people here, I’m still open for suggestions.
tldr;
Starting from input asset, what’s the first step for a tool taking it as “input” somehow to generate a rebind screen?
Is there a way to generalize the code enough to do that?
I gave you every help to you to be able to finish your task. I can write the stuff for you, $100 is my hourly rate, min. 1 hour. Hit me up in PM if you’re interested.
Interesting way to say thank you when someone tries to help you…
When asking for help, and someone helps you, the appropriate response is “Thank you”. Since you are not interested in the help being offered, no point in this topic remaining open. Closed.