1
\$\begingroup\$

In Unity in InputManager I assigned R Button to "Restart" name.

Now that property (Restart) has another property with a key "Positive Button" and string value "R".

enter image description here

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 button.

enter image description here

Now the 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 uses UnityEditor.dll

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Unfortunatly, this isn't possible right now.
Like you said, it uses the Editor library.
The only option left is to use an entierely different system to manage all inputs. Take a look on the asset store for system like this.

\$\endgroup\$
1
  • \$\begingroup\$ Unfortunatly, this isn't possible right now. - it is 100% ? )) Why do developers not do that functionality? How do they explain that? And what for start config window needs then? .............Thanks for the link, but without Start Config Window I can make Input Manager myself =)) \$\endgroup\$ Commented Dec 28, 2016 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .