it quite simple really, but it might require a bit of setup,
1- add a sphere collider to the player and set it as a trigger.
2- increases sphere collider radius to your liking, that sphere will become your range attack range (you could control it in the script if you want)
3- now create a new script, the script will have a “list” let call it targetHolder, onTriggerEnter method, add any game object to targetHolder with tag enemy, you have to make sure if that object isn’t already inside the list or not.
4- have a button on the gamepad that circle through the list. and set it as an attack target.
hint: you can reorder the list based on the distance from the player to the targets.
there is two Trigger related methods, OntriggerStay, and onTriggerExit
I made that script in a game jam event, but I do not mind sharing it