I saw a couple of questions along these lines but there's differences.
I'm trying to accomplish a couple of things here. One a enemy detection by searching a radius every so often. Second I'd like to use the same sort of function to create an AOE damage effect. I've already created a GetDistance from two objects. From previous RPG games a function was created called GetFirst and GetNext and was very nice and I'd like to replicate that again.
This code would run on a WHILE going through the game objects one at a time till they return to the first one. Inside this I would use my GetDistance to determine if they can be targeted or not (AOE spells). I have a lot of other uses for this as well.
I know how to find objects by name, but is there a way to just go through each object? (running it as code should be pretty quick as its just running a small function (GetDistance).
If your enemies have colliders attached, you can use Physics.OverlapSphere to quickly get your initial list of enemies within a certain radius.
You can then loop through each enemy within this list and determine the relative distance to the player, and apply some level of damage to each enemy within the radius, proportional to its distance.
It would end up looking something like this. It assumes that your enemy objects have both a collider and a script called "Enemy" attached.
(untested code, for illustration only!)