---
title: EventTrigger
slug: world-sdk-guide/eventtrigger
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

The EventTrigger receives events from the Unity EventSystem and calls the registered functions.

To use the Unity EventTrigger in ZEPETOScript, you must follow the format given below.

First, for testing purposes, add UI > Panel to the Scene.

::Image[]{src="https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-TWCfIp1gFAkNXaqWNG7ta-20240904-102419.png" size="54" width="634" height="1100" position="center" showCaption="false"}



Click \[Add Component] in the inspector of the added Panel, and add the Event Trigger component.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-kowTbqgz-BU4oqeKjk0pu-20240904-102419.png)



## Example Script

First, import the classes related to the EventTrigger.

:::CodeblockTabs
TypeScript

```typescript
import { EventTrigger, EventTriggerType } from 'UnityEngine.EventSystems';
import { Entry } from 'UnityEngine.EventSystems.EventTrigger';
```
:::

Write code to delegate the EventTrigger. Through the delegate, you can define callback methods and call methods on behalf of others.

:::hint{type="success"}
**👍 Concept of Delegate**

- A Delegate can be seen as a type of function pointer, which is an object that can reference and call a function.
- It can pass or return a function like a variable, and can also be passed as a parameter to other functions.
- In Unity, delegates are widely used for event handling. For example, you can connect a method to a delegate to have it automatically called whenever a specific event occurs.
:::



:::CodeblockTabs
TypeScript

```typescript
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { EventTrigger, EventTriggerType } from 'UnityEngine.EventSystems';
import { Entry } from 'UnityEngine.EventSystems.EventTrigger';
  
export default class EventTriggerSample extends ZepetoScriptBehaviour {
 
    Start() {
        const trigger = this.gameObject.GetComponent<EventTrigger>();
 
        // Create eventsystem entry
        const entry = new Entry();
 
        // Specify event type & delegation
        entry.eventID = EventTriggerType.PointerClick;
        entry.callback.AddListener(() => {
            console.log("click")
        });
 
        // Register event entry
        trigger.triggers.Add(entry);
 
    }
}
```
:::



Refer to the screen shown below.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-O0O3hwH_bVE4NRbl2UvZC-20240904-102419.png)



Check the full code example for Event Trigger.

:::CodeblockTabs
EventTriggerSample

```typescript
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { EventTrigger, EventTriggerType } from 'UnityEngine.EventSystems';
import { Entry } from 'UnityEngine.EventSystems.EventTrigger';
 
export default class EventTriggerSample extends ZepetoScriptBehaviour {

    Start() {
        const trigger = this.gameObject.GetComponent<EventTrigger>();

        // Create eventsystem entry
        const entry = new Entry();

        // Specify event type & delegation
        entry.eventID = EventTriggerType.PointerClick;
        entry.callback.AddListener(() => {
            console.log("click")
        });

        // Register event entry
        trigger.triggers.Add(entry);

    }
}
```
:::



You can learn more about types of events supported by Unity and the EventTrigger by clicking the links below.

:::hint{type="info"}
**📘 Supported events**
[https://docs.unity3d.com/kr/current/Manual/SupportedEvents.html](https://docs.unity3d.com/kr/current/Manual/SupportedEvents.html)
:::

:::hint{type="info"}
**📘 EventTrigger**
[https://docs.unity3d.com/kr/530/ScriptReference/EventSystems.EventTrigger.html](https://docs.unity3d.com/kr/530/ScriptReference/EventSystems.EventTrigger.html)
:::

