public static bool AddAxis( AxisDefinition axis )
{
if( AxisDefined( axis.name ) )
{
return false;
}
SerializedObject serializedObject = new SerializedObject( AssetDatabase.LoadAllAssetsAtPath( "ProjectSettings/InputManager.asset" )[0] );
SerializedProperty axesProperty = serializedObject.FindProperty( "m_Axes" );
axesProperty.arraySize++;
serializedObject.ApplyModifiedProperties();
SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex( axesProperty.arraySize - 1 );
GetChildProperty( axisProperty, "m_Name" ).stringValue = axis.name;
GetChildProperty( axisProperty, "descriptiveName" ).stringValue = axis.descriptiveName;
GetChildProperty( axisProperty, "descriptiveNegativeName" ).stringValue = axis.descriptiveNegativeName;
GetChildProperty( axisProperty, "negativeButton" ).stringValue = axis.negativeButton;
GetChildProperty( axisProperty, "positiveButton" ).stringValue = axis.positiveButton;
GetChildProperty( axisProperty, "altNegativeButton" ).stringValue = axis.altNegativeButton;
GetChildProperty( axisProperty, "altPositiveButton" ).stringValue = axis.altPositiveButton;
GetChildProperty( axisProperty, "gravity" ).floatValue = axis.gravity;
GetChildProperty( axisProperty, "dead" ).floatValue = axis.dead;
GetChildProperty( axisProperty, "sensitivity" ).floatValue = axis.sensitivity;
GetChildProperty( axisProperty, "snap" ).boolValue = axis.snap;
GetChildProperty( axisProperty, "invert" ).boolValue = axis.invert;
GetChildProperty( axisProperty, "type" ).intValue = (int)axis.type;
GetChildProperty( axisProperty, "axis" ).intValue = axis.axis - 1;
GetChildProperty( axisProperty, "joyNum" ).intValue = axis.joyNum;
serializedObject.ApplyModifiedProperties();
return true;
}