Hi, there is no action such as this. This is not a function of raycast. However, I might do it this way.
Raycast tells you which object it has hit. Save that object as a variable. When the ray hits a new object, send a global event to that object. Something like "On Global Enter". Make sure to setup this global variable on the object. (Any objects you want to be hit).
Then that object will know it has been hit.
Save that object variable to a second variable (so it doesnt get removed when you get to the next object). Use it to compare. Compare if object has changed. (If it is not the same anymore, then you know you have moved to the next object. Send the old object a global custom event for exit. Send the new object your on global enter). If it hasent changed, do nothing.
You can put those objects you want hit on a specific layer. So the ray cast will only hit those objects. That way, you dont send any extra un-necessary events to other objects that are not setup for it. (You can send events to them, but its just a waste).
Let me know if you understood that.