using System; using Reset; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UIElements; namespace Reset.Units{ public class InputFinder : MonoBehaviour{ public InputActionMap actionMap; void Start(){ actionMap.actions[0].performed += ctx => { InputPressed(ctx); }; GetComponent().enabled = false; } public void AwaitNewInput(){ PlayerManager.ClearCurrentController(); GetComponent().enabled = true; actionMap.Enable(); } void InputPressed(InputAction.CallbackContext context){ try { PlayerManager.AttachControllerToPlayer(context.control.device); } catch (Exception e) { Debug.LogError($"Failed to set the new device to the player: {e.Message}"); return; } GetComponent().enabled = false; actionMap.Disable(); } } }