InputManager Constants File

Currently when i want to get if the user press a button that i bind as “Fire1” i have to use Input.GetButton("Fire1")In my experience(In Web and Mobile Development), the use of Strings Literals is a bad practice because if i want to change “Fire1” to “Fire”(by example)… then i have to change the String Literal everywhere i use it and that may cause multiple errors that only can be catched if i run the game.

I think an autogenerated file named “InputNames” (by example) may improve the code readability and maintainability using Input.getButton(InputNames.Fire1)

Thanks :smile:

That input system’s now the “old” input system. The new one is event based.

On that note, automatically generated classes wouldn’t be very useful here because it wouldn’t change usages of those constants in your code if you renamed them (unless it didn’t rename the identifier, but then it’s out of sync). A manually written static class with a bunch of constants is much more reliable, and you can change the names using your IDE’s refactoring functionality.

public static class InputNames
{
    public const string Fire1 = nameof(Fire1);
    // ...
}