I’m trying to Raycast in scene view based mouse position. I pretty much want to mimic the unity’s behavior when you click some where it selects that objects except I wish to get all the objects through that ray.
Here’s exactly what I want to do:
- Press a button on the inspector of a script to start Raycasting.
- As user moving through scene it selects (keeps record of) all the objects that intersect with ray from current mouse position.
- Then user clicks in the scene view to stop the Raycasting and the last set of selected objects is shown in the inspector.
I’ve search and not seen a solution that works. It seems like such a trivial thing to be able to do.
So if anyone can create a simple script of function that works that would be great.
Here’s a link to what I have so far: (link is dead)https://gist.github.com/lordlycastle/fdc919da37585410309df3231ed03e00
Thanks for this. I used the first option until I noticed that the rays were very wrong on MacOS Editor 2019.4. The second version works well on all platforms I tested. And unlike the first line, the second one does not require flipping the y coordinate or accounting for an offset that the scene view toolbar introduces.
– Viand