Version: 2019.3
Debugging C# code in Unity
Messaging System

Event System

Система событий - способ отправки событий к объектам в приложении, основанный на вводе с клавиатуры или мыши; с помощью касаний или персональных устройств. Система состоит из нескольких компонентов, работающих вместе.

When you add an Event System component to a GameObject you will notice that it does not have much functionality exposed, this is because the Event System itself is designed as a manager and facilitator of communication between Event System modules.

Первичные роли системы событий:

  • определяет какой объект считается выделенным
  • определяет какой InputModule используется
  • управляет райкастингом (если нужно) Обновление всех модулей ввода (InputModules), если требуется.

Input Modules

An Input Module is where the main logic of how you want the Event System to behave lives, they are used for:

  • Обработки ввода
  • Управления состояниями событий
  • Отправки событий объектам на сцене.

Только один модуль ввода может быть активным в системе событий одновременно. Он должен находиться на том же игровом объекте, что и компонент EventSystem.

If you want to write a custom Input Module, send events supported by existing UI components in Unity. To extend and write your own events, see the Messaging System documentation.

Raycasters

Raycasters are used for figuring out what the pointer is over. It is common for Input Modules to use the Raycasters configured in the Scene to calculate what the pointing device is over.

По умолчанию, предоставляется 3 трассировщика лучей:

If you have a 2d / 3d Raycaster configured in your Scene, it is easy to make non-UI elements receive messages from the Input Module. Simply attach a script that implements one of the event interfaces. For examples of this, see the IPointerEventHandle and IPointerClickHandler Scripting Reference pages.

Debugging C# code in Unity
Messaging System
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961