Is such a function available? I have a lot of objects in my scene that are activated through raycasts and its very time consuming to check the hit for each object rather than just running OnHit on each object
I don’t think there is such a function.
you can add a “OnRayHit” Script to your object. Then let your raycast check if the object has that script assigned and if so call the needed function in that script.