Hello Unity community.

What’s the best way to detect if there’s a collider between 2 gameObjects position in a straight line?

Any ideas will be appreciated.

line cast will work for you.
first hit the middle collider with line cast. after hitting take that hit direction and send a ray in same direction to the another object.
try this one

     if(Physics.Linecast(transform.position,target.position,out hit))
	{
			Vector3 raycastDir = hit.point - (Vector3)transform.position;
                if(Physics.Raycast(hit.point,raycastDir, out hit1))
		   {
     debug.log("hit");

  }
   }