이벤트 시스템은 운영체제나 스크립트에서 오는 이벤트를 수신한 다음, EventDispatcher를 사용하여 이러한 이벤트를 시각적 요소에 디스패치합니다. 이벤트 디스패처는 전송하는 각 이벤트에 대해 적절한 디스패칭 전략을 결정합니다. 전략을 결정하고 나면 해당 전략을 실행합니다.
시각적 요소는 여러 이벤트에 대한 기본 동작을 구현합니다. 여기에는 추가 이벤트의 생성 및 실행이 포함됩니다. 예를 들어 PointerMoveEvent
는 추가 PointerEnterEvent
및 PointerLeaveEvent
를 생성할 수 있습니다. 이러한 이벤트는 대기열에 들어가며 현재 이벤트 다음으로 처리됩니다. 예를 들어 PointerMoveEvent
는 PointerEnterEvent
및 PointerLeaveEvent
이벤트보다 먼저 처리됩니다.
각 이벤트 타입에는 자체 디스패치 동작이 있습니다. 각 이벤트 타입의 동작은 두 개의 단계로 분류됩니다.
각 이벤트 타입의 디스패치 동작 리스트는 이벤트 레퍼런스 페이지를 참조하십시오.
이벤트 디스패처는 이벤트 타겟을 선택한 후 이벤트의 전파 경로를 계산합니다. 전파 경로는 이벤트를 수신하는 시각적 요소의 순서 리스트입니다. 전파 경로는 다음 순서로 생성됩니다.
대부분의 이벤트 타입은 전파 경로를 따라 모든 요소에 전송됩니다. 일부 이벤트 타입은 버블업 단계를 건너뛰며, 일부 이벤트 타입은 이벤트 타겟으로만 보내집니다.
숨기거나 비활성화한 요소는 이벤트를 수신하지 않습니다. 하지만 이벤트는 숨겨지거나 비활성화된 요소의 조상과 자손으로 계속 전파됩니다.
이벤트가 전파 경로를 따라 이동하면 Event.currentTarget
이 이벤트를 처리하는 요소에 업데이트됩니다. 이벤트 콜백 함수 내에는 디스패치 동작을 기록하는 프로퍼티가 두 가지 있습니다.
EventBase.currentTarget
은 콜백이 등록된 시각적 요소입니다.EventBase.target
은 이벤트가 발생한 요소(예: 포인터 바로 아래의 요소)입니다.이벤트의 타겟은 이벤트 타입에 기반합니다. 포인터 이벤트의 경우 타겟은 보통 포인터 바로 아래에 있는 선택 가능한 최상위 요소입니다. 키보드 이벤트의 경우 타겟은 현재 포커스가 있는 요소입니다.
UI 툴킷 이벤트에는 이벤트가 발생한 요소에 대한 레퍼런스가 포함된 target
프로퍼티가 있습니다. 운영체제에서 발생한 대다수 이벤트의 경우, 디스패치 프로세스가 이벤트 타겟을 자동으로 찾습니다.
타겟 요소는 EventBase.target
에 저장되며, 디스패치 프로세스 중 변경되지 않습니다. 현재 이벤트를 처리하는 시각적 요소에 Event.currentTarget
이 업데이트됩니다.
대부분의 포인터 이벤트는 선별 모드를 사용하여 타겟을 결정합니다. VisualElement
클래스에는 다음의 값을 지원하는 pickingMode
프로퍼티가 있습니다.
PickingMode.Position
(기본값): 포지션 직사각형에 따라 선별을 수행합니다.PickingMode.Ignore
: 포인터 이벤트의 결과에 따라 선별을 방지합니다.VisualElement.ContainsPoint()
메서드를 오버라이드하여 커스텀 교차 로직을 수행할 수 있습니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.