Version: 2022.3
LanguageEnglish
  • C#

EventDispatcherGate

struct in UnityEngine.UIElements

/

Implemented in:UnityEngine.UIElementsModule

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

Submission failed

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

Close

Cancel

Description

Gates control when the dispatcher processes events.

Here is an example of using a gate:

When the gate is instantiated, it closes automatically, causing the dispatcher to store the events it receives in a queue. At the end of the using block, Dispose is called, which triggers opening the gate. When all gates on a dispatcher open, the events stored in the queue are processed. Closing a gate while the event queue is processed does not stop it from being processed. Instead, a new queue is created to store new events.

Here is an example of using a gate:

 public class MyElement : VisualElement
 {
     void Foo()
     {
         using (new EventDispatcherGate(dispatcher))
         {
             // do something that sends events
         }
     }
 }

Constructors

EventDispatcherGate Constructor.

Public Methods

Dispose Implementation of IDisposable.Dispose. Opens the gate. If all gates are open, events in the queue are processed.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961