using UnityEngine; using UnityEditor; using System.Collections.Generic; public class GameInputSetup { [MenuItem("Tools/Setup Complete Game Input")] public static void SetupGameInput() { var inputManagerPath = "ProjectSettings/InputManager.asset"; var serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath(inputManagerPath)[0]); var axesProperty = serializedObject.FindProperty("m_Axes"); // First clear any existing duplicates ClearExistingAxes(axesProperty); var axes = new List() { // Movement - Left Stick new InputAxis() { name = "Horizontal", descriptiveName = "Left Stick Horizontal", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 0, joyNum = 0 }, new InputAxis() { name = "Vertical", descriptiveName = "Left Stick Vertical", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 1, invert = true, joyNum = 0 }, // Keyboard Movement new InputAxis() { name = "Horizontal", negativeButton = "a", positiveButton = "d", gravity = 3f, sensitivity = 3f, type = 0, }, new InputAxis() { name = "Vertical", negativeButton = "s", positiveButton = "w", gravity = 3f, sensitivity = 3f, type = 0, }, // Aiming - Right Stick new InputAxis() { name = "RightStickHorizontal", descriptiveName = "Right Stick Horizontal", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 3, joyNum = 0 }, // Alternative mapping for different controllers new InputAxis() { name = "RightStickHorizontal", descriptiveName = "Right Stick Horizontal Alt", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 5, joyNum = 0 }, new InputAxis() { name = "RightStickVertical", descriptiveName = "Right Stick Vertical", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 4, invert = true, joyNum = 0 }, // Alternative mapping for different controllers new InputAxis() { name = "RightStickVertical", descriptiveName = "Right Stick Vertical Alt", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 6, invert = true, joyNum = 0 }, // Primary Abilities (Face Buttons) new InputAxis() { name = "Ability1", descriptiveName = "Primary Ability (A/X)", positiveButton = "joystick button 0", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability1", positiveButton = "1", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability2", descriptiveName = "Secondary Ability (B/Circle)", positiveButton = "joystick button 1", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability2", positiveButton = "2", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability3", descriptiveName = "Third Ability (X/Square)", positiveButton = "joystick button 2", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability3", positiveButton = "3", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability4", descriptiveName = "Fourth Ability (Y/Triangle)", positiveButton = "joystick button 3", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Ability4", positiveButton = "4", gravity = 1000, sensitivity = 1000, type = 0 }, // UI and Special Actions new InputAxis() { name = "Interact", descriptiveName = "Interact/Confirm", positiveButton = "joystick button 0", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Interact", positiveButton = "e", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Menu", descriptiveName = "Menu/Pause", positiveButton = "joystick button 7", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Menu", positiveButton = "escape", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Inventory", descriptiveName = "Inventory Toggle", positiveButton = "joystick button 6", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "Inventory", positiveButton = "i", gravity = 1000, sensitivity = 1000, type = 0 }, // Shoulder Buttons and Triggers new InputAxis() { name = "LeftTrigger", descriptiveName = "Left Trigger", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 8, joyNum = 0 }, new InputAxis() { name = "RightTrigger", descriptiveName = "Right Trigger", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 9, joyNum = 0 }, new InputAxis() { name = "LeftBumper", descriptiveName = "Left Bumper", positiveButton = "joystick button 4", gravity = 1000, sensitivity = 1000, type = 0 }, new InputAxis() { name = "RightBumper", descriptiveName = "Right Bumper", positiveButton = "joystick button 5", gravity = 1000, sensitivity = 1000, type = 0 }, // D-Pad new InputAxis() { name = "DPadHorizontal", descriptiveName = "D-Pad Horizontal", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 5, joyNum = 0 }, new InputAxis() { name = "DPadVertical", descriptiveName = "D-Pad Vertical", deadZone = 0.2f, sensitivity = 1f, type = 2, axis = 6, invert = true, joyNum = 0 } }; foreach (var axis in axes) { AddAxis(axesProperty, axis); } serializedObject.ApplyModifiedProperties(); Debug.Log("Input Manager setup complete! All game controls have been configured."); } private static void ClearExistingAxes(SerializedProperty axesProperty) { var axesToClear = new HashSet { "RightStickHorizontal", "RightStickVertical", "Ability1", "Ability2", "Ability3", "Ability4", "LeftTrigger", "RightTrigger", "LeftBumper", "RightBumper", "DPadHorizontal", "DPadVertical" }; var axesToRemove = new List(); for (int i = 0; i < axesProperty.arraySize; ++i) { var axisProp = axesProperty.GetArrayElementAtIndex(i); var name = axisProp.FindPropertyRelative("m_Name").stringValue; if (axesToClear.Contains(name)) { axesToRemove.Add(i); } } for (int i = axesToRemove.Count - 1; i >= 0; --i) { axesProperty.DeleteArrayElementAtIndex(axesToRemove[i]); } } private static void AddAxis(SerializedProperty axesProperty, InputAxis axis) { axesProperty.arraySize++; var axisProperty = axesProperty.GetArrayElementAtIndex(axesProperty.arraySize - 1); axisProperty.FindPropertyRelative("m_Name").stringValue = axis.name; axisProperty.FindPropertyRelative("descriptiveName").stringValue = axis.descriptiveName; axisProperty.FindPropertyRelative("descriptiveNegativeName").stringValue = axis.descriptiveNegativeName; axisProperty.FindPropertyRelative("negativeButton").stringValue = axis.negativeButton; axisProperty.FindPropertyRelative("positiveButton").stringValue = axis.positiveButton; axisProperty.FindPropertyRelative("altNegativeButton").stringValue = axis.altNegativeButton; axisProperty.FindPropertyRelative("altPositiveButton").stringValue = axis.altPositiveButton; axisProperty.FindPropertyRelative("gravity").floatValue = axis.gravity; axisProperty.FindPropertyRelative("dead").floatValue = axis.deadZone; axisProperty.FindPropertyRelative("sensitivity").floatValue = axis.sensitivity; axisProperty.FindPropertyRelative("snap").boolValue = axis.snap; axisProperty.FindPropertyRelative("invert").boolValue = axis.invert; axisProperty.FindPropertyRelative("type").intValue = axis.type; axisProperty.FindPropertyRelative("axis").intValue = axis.axis; axisProperty.FindPropertyRelative("joyNum").intValue = axis.joyNum; } } [System.Serializable] public class InputAxis { public string name = ""; public string descriptiveName = ""; public string descriptiveNegativeName = ""; public string negativeButton = ""; public string positiveButton = ""; public string altNegativeButton = ""; public string altPositiveButton = ""; public float gravity = 0f; public float deadZone = 0f; public float sensitivity = 0f; public bool snap = false; public bool invert = false; public int type = 0; public int axis = 0; public int joyNum = 0; }