Skip to main content
added 2 characters in body
Source Link
jzx
  • 3.8k
  • 2
  • 24
  • 38

FOUND THIS

only usableManipulating the Input Manager in Script gives a solution for editor codes script:

/// <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, this is only safe in the editor, and not while the game is running.

FOUND THIS

only usable for editor codes :

/// <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;
     }

Manipulating the Input Manager in Script gives a solution for editor script:

/// <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, this is only safe in the editor, and not while the game is running.

Source Link

FOUND THIS

only usable for editor codes :

/// <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;
     }