How do I get Input Positive Button value in Runtime?

In InputManager I assigned R Button to “Restart” name.
Now “Restart” has key “Positive Button” and string value “R”.


Now in the game I can show notice to user: “click R for Restart!”
But what if user will change that key in the start config window? For example from R to T.

Game should display notice: “click T for Restart!”

Question: How do I get changed Positive Button value by name “Restart” via script in Runtime? Is it possible?


p.s. in Editor I can do this:

SerializedObject inputManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
SerializedProperty axisArray = inputManager.FindProperty("m_Axes");

for (int i = 0; i < axisArray.arraySize; ++i) {
    var axis = axisArray.GetArrayElementAtIndex(i);
    var axisName = axis.FindPropertyRelative("m_Name").stringValue;
    if (axisName == "Restart") {
        restartButtonValue = axis.FindPropertyRelative("positiveButton").stringValue;
        break;
    }
}

But it allows to use it only in the Editor. Because it use UnityEditor.dll

2 Likes

I don’t know if it’s still the case, but in 2012 Eric5h5 said, that’s it’s not possible:

Why do developers not do that functionality? How do they explain that? And what for start config window needed then?

They’re working on a new input system. In the meantime, there are assets you can buy on the store.

–Eric