UnityGame/Library/PackageCache/com.unity.ugui/Documentation~/Raycasters.md
2024-10-27 10:53:47 +03:00

1.0 KiB

Raycasters

A Raycaster is a component that determines what objects are under a specific screen space position, such as the location of a mouse click or a touch. It works by projecting a ray from the screen into the scene and identifying objects that intersect with that ray. Raycasters are essential for detecting user interactions with UI elements, 2D objects, or 3D objects.

Different types of Raycasters are used for different types of objects:

The Event System uses Raycasters to determine where to send input events. When a Raycaster is present and enabled in the scene, the Event System uses it to determine which object is closest to the screen at a given screen space position. If multiple Raycasters are active, the system will cast against all of them and sort the results by distance.