Function: createUiRaycastEcsSystem()
createUiRaycastEcsSystem(
pointerSource,renderContext):EcsSystem<[CanvasEcsComponent]>
Defined in: ui/systems/ui-raycast-system.ts:146
Creates a system that, per CanvasEcsComponent, converts the pointer
source's position into that canvas's UI world space and scans its
UiInteractableEcsComponents in reverse hierarchy order (topmost first,
by RectTransformEcsComponent.sortDepth) for the first whose resolved
rect contains it - a linear reverse-depth scan: element counts here are
in the hundreds, not the hundreds of thousands, so a plain scan is a few
microseconds with no acceleration structure to build or invalidate. An
element with blocksRaycasts: false is transparent to the scan (never
considered, hit or not) - so is one with an ancestor
CanvasGroupEcsComponent whose own blocksRaycasts is false (see
resolveCanvasGroupState); an element culled from the canvas's camera by
cullingMask is skipped the same way an invisible element shouldn't be
clickable.
Writes CanvasEcsComponent.hoveredEntity (the topmost hit, or null) and
isPointerOverUi (hoveredEntity !== null) every tick - read by
createUiInteractionEcsSystem and by game systems wanting to gate world
interaction on "did this click land on the UI".
Must be registered after createUiLayoutEcsSystem (it reads the rects/
sortDepths that system resolves) and before createUiInteractionEcsSystem.
Parameters
pointerSource
The pointer source hit-tested against.
renderContext
The render context canvases' cameras render through, used to convert the pointer position.
Returns
EcsSystem<[CanvasEcsComponent]>
The UI raycast ECS system.