C#: Is there no built in cache for input action names?

Godot Version

4.2.1

Question

For many things where Godot requires strings, there are caches that can be used instead of typing strings by hand. Like SignalName or MethodName. But I haven’t found one for action names. Is it true that there is none?

no IntelliSense in Godot Editor for C#,
If you want something lightweight you can use Visual Studio Code with C# plugins.

Check out InputMap.GetActions()

It won’t provide intellisense, but it can be used to get an action name list.

gdscript:

func _ready():
	var _res = InputMap.get_actions();
	for _act in _res:
		print (".gd: Action: '", _act, "'");

c#:

    public override void _Ready() {
        var _allActions = Godot.InputMap.GetActions();
        foreach (var _act in _allActions) {
            GD.Print(".cs: Action: '", _act, "'"); } }
2 Likes

I am using Visual Studio Code with several Godot extensions. Is there one that provides cached input actions from Godot’s input map?

Late to the party, but look at StringNames, that was made for caching

1 Like

There is nothing comparable to SignalName or MethodName for input actions built in. Although, it should be quite straightforward to implement on the project side. For instance, here is my own version of it. Keep it in mind, input maps can be modified at runtime. So those constants might not be valid, depending on how you are managing input maps in your game (and that is part of the rationale why such thing is not built in).

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.