using UnityEngine; using UnityEditor; #if UNITY_EDITOR /// /// Utility class to help set up the animation system with the input system. /// This can be accessed from the Unity Editor menu. /// public class InputAnimationSetup : MonoBehaviour { [MenuItem("Tools/Setup Input Animation System")] public static void SetupInputAnimationSystem() { // Find the player character (assuming it has a PlayerInput component) var playerInputs = UnityEngine.Object.FindObjectsByType(UnityEngine.FindObjectsSortMode.None); if (playerInputs.Length == 0) { Debug.LogError("No PlayerInput component found in the scene. Make sure your player character has a PlayerInput component."); return; } GameObject targetObject = null; // If there are multiple PlayerInput components, show a selection dialog if (playerInputs.Length > 1) { Debug.LogWarning("Multiple PlayerInput components found. Selecting the first one."); targetObject = playerInputs[0].gameObject; } else { targetObject = playerInputs[0].gameObject; } if (targetObject == null) { Debug.LogError("Failed to find a suitable target object."); return; } // Check if the target object already has an AnimationManager AnimationManager animManager = targetObject.GetComponent(); if (animManager == null) { animManager = targetObject.AddComponent(); Debug.Log("Added AnimationManager to " + targetObject.name); } // Check if the target object already has an InputToAnimation InputToAnimation inputAnim = targetObject.GetComponent(); if (inputAnim == null) { inputAnim = targetObject.AddComponent(); Debug.Log("Added InputToAnimation to " + targetObject.name); } // Configure the InputToAnimation component with default mappings for our 8 core animations SerializedObject serializedInputAnim = new SerializedObject(inputAnim); serializedInputAnim.FindProperty("jabInputAction").stringValue = "Jab"; serializedInputAnim.FindProperty("haymakerInputAction").stringValue = "Haymaker"; serializedInputAnim.FindProperty("spinningBackfistInputAction").stringValue = "SpinningBackfist"; serializedInputAnim.FindProperty("elbowSmashInputAction").stringValue = "ElbowSmash"; serializedInputAnim.FindProperty("airPunchInputAction").stringValue = "AirPunch"; serializedInputAnim.FindProperty("lowKickInputAction").stringValue = "LowKick"; serializedInputAnim.FindProperty("basicKickInputAction").stringValue = "BasicKick"; serializedInputAnim.FindProperty("sumoSlapInputAction").stringValue = "SumoSlap"; serializedInputAnim.ApplyModifiedProperties(); // Make sure the target object has an Animator component Animator animator = targetObject.GetComponent(); if (animator == null) { animator = targetObject.AddComponent(); Debug.LogWarning("Added Animator component to " + targetObject.name + ", but you'll need to assign an animator controller to it."); } // Display info about which animations are active Debug.Log("Only the following 8 animations are currently active:"); Debug.Log("- Jab\n- Haymaker\n- BasicKick\n- SumoSlap\n- SpinningBackfist\n- ElbowSmash\n- AirPunch\n- LowKick"); Debug.Log("Other animations have been commented out for future use."); Debug.Log("Legacy direct triggers in PlayerScript have been neutralized. InputToAnimation now exclusively drives animations via the new Input System."); // Select the object in the inspector for easier configuration Selection.activeGameObject = targetObject; Debug.Log("Input Animation System setup complete for " + targetObject.name); Debug.Log("Make sure all animation clips are properly set up in your Animator Controller!"); } } #endif