Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if UNITY_EDITOR
- using System.Collections.Generic;
- using UnityEditor;
- public class InputManagerAsset
- {
- public enum InputType
- {
- KeyOrMouseButton,
- MouseMovement,
- JoystickAxis
- };
- public static void ReadAxes( List<string> names = null , List<InputType> types = null )
- {
- names.Clear();
- types.Clear();
- var inputManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
- SerializedObject obj = new SerializedObject(inputManager);
- SerializedProperty axisArray = obj.FindProperty("m_Axes");
- if( axisArray.arraySize == 0 )
- return;
- for( int i = 0; i < axisArray.arraySize; ++i )
- {
- SerializedProperty axis = axisArray.GetArrayElementAtIndex(i);
- string name = axis.FindPropertyRelative("m_Name").stringValue;
- if( string.IsNullOrEmpty( name ) )
- continue;
- if( names != null )
- names.Add( name );
- InputType inputType = (InputType)axis.FindPropertyRelative("type").intValue;
- if( types != null )
- types.Add( inputType );
- }
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement