Enemy AI movement on a platform (left and right) 2D

I made some graphics and put them as platforms and add them a edge collider. So next i want to make an enemy AI movement on this platform only on the edges of it, when it is on the left edge i want to turn and move to the other side of the platform and back again. Also i want to do this on every platform i put on an enemy. There is any easy way to make it happen ?

You could use one raycast from the enemy pointed down and forwards a short distance. If it doesn’t return something tagged as ground, turn around.
I have also used empty box colliders set as trigger that enemies recognize as bounds OnTriggerEnter, but if there are many platforms that can get tedious.