Legacy Documentation: Version 4.6.2
Language: English
Supported Events
Event System Manager

Raycasters

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

The EventSystem needs a method for detecting where current input events need to be sent to, and this is provided by the Raycasters. Given a screen space position they will collect all potential targets, figure out if they are under the given position, and then return the object that is closest to the screen. There are a few types of Raycasters that are provided:

  • GraphicRaycaster - Used for UI elements, lives on a Canvas and searches within the canvas
  • Physics2DRaycaster - Used for 2D physics elements
  • PhysicsRaycaster - Used for 3D physics elements

When a Raycaster is present and enabled in the scene it will be used by the EventSystem whenever a query is issued from an InputModule.

If multiple Raycasters are used then they will all have casting happen against them and the results will be sorted based on distance to the elements.

Supported Events
Event System Manager