I'm trying to figure out how Graphic.Raycaster works, but documentation doesn't help. I want to use it to cast raycast from some position an certain angle and hit UI. The other thing is that I don't know how to make it interact with UI(drag, click etc.). I know that's broad subject, but I just can't find any good explanation of what it actually is and how to use it, so I would be grateful for any explanation.
相关问题
- Unity - Get Random Color at Spawning
- Unity3D WebGL Headless not rendering
- Unity3D loading resources after build
- Load Image from Stream/StreamReader to Image OR Ra
- Unity3D - Build Failed because of “[Unity] ERROR:
相关文章
- Programmatically setting and saving the icon assoc
- Omnisharp in VS Code produces a lot of warnings ab
- Call non-static methods on custom Unity Android Pl
- How can a game created in Unity can run on an Andr
- How to add Persistent Listener to Button.onClick e
- Placing an object in front of the camera
- Connecting Unity3d Android application to ActiveMQ
- How to mimic HoloLens 2 hand tracking wIth Windows
Umair M's current suggestion doesn't handle the fact that the ray is originating in world space and traveling at an angle.
It doesn't look to me like you can do a GUI raycast in world space at an angle even if your canvas is in world space. This page suggests a technique of creating a non-rendering camera, moving it around in 3D space with the ray you want to cast, and then doing the GUI raycast relative to that camera. I haven't tried it yet, but it sounds promising.
From Unity docs:
You can use
EventSystem.RaycastAll
toraycast
against graphics(UI) elements.Here is a short example for your case:
The above script is not tested by myself. So there might be some errors.
Here are some other references to help you understand more:
Hope it helps.