public static int Closest(List</*GameObject*/PathNode> inNodes, Vector3 toPoint)
{
int closestIndex = 0;
float minDist = float.MaxValue;
for(int i = 0; i < inNodes.Count; i++)
{
if(AStarHelper.Invalid(inNodes[i]/*.GetComponent<PathNode>()*/))
continue;
float thisDist = Vector3.Distance(toPoint, inNodes[i]/*.GetComponent<PathNode>()*/.Position);
if(thisDist > minDist)
continue;
minDist = thisDist;
closestIndex = i;
}
if (minDist != float.MaxValue)
return closestIndex;
else
return -1;
}