How do you get the button names assigned to an axis in the InputManager?

I have assigned some hotkeys in the InputManager. I would like to display the key assigned (e.g. in a tooltip) and update it if the player changes it, but I do not see a way to access it. Is that not possible? Or maybe I am using it incorrectly?

what are you using it for if its not too much of a priority you can intergrate it

3 Answers

3

Unfortunately it's not possible. Vote for improvements in scripting access to the input manager here.

Amazing this still hasn’t been built in yet.

Yo Unity! This needs to be a thing. Some people might want to allow the player to change their controls, mid-game. You know, like most games allow…

Check this out http://www.plyoung.com/blog/manipulating-input-manager-in-script.html - Like Eric pointed out, only usable for editor codes though

	/// <summary>
	/// Gets all the input axis defined in the project's Input manager
	/// (gets it from ProjectSettings/InputManager.asset)
	/// </summary>
	public static List<string> GetInputAxis()
	{
		var allAxis = new List<string>();

		var serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
		var axesProperty = serializedObject.FindProperty("m_Axes");

		axesProperty.Next(true);
		axesProperty.Next(true);
		while (axesProperty.Next(false))
		{
			SerializedProperty axis = axesProperty.Copy();
			axis.Next(true);
			allAxis.Add(axis.stringValue);
		}

		return allAxis;
	}

Unfortunately that's only for editor scripting. What's needed is a way to do it at runtime.

Ahh yeah... oh well, at least there's a way to do it for editor codes. I couldn't even find anything related in their editor dll

Sorry I hadnt noticed you'd already posted that link :D Got too excited

link was updated: http://plyoung.appspot.com/blog/manipulating-input-manager-in-script.html