Studio GuideWorld SDK Guide
Log In

Event Trigger

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.

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

Example Script

First, import the classes related to the EventTrigger.

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.


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.

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(() => {
        // Register event entry

Refer to the screen shown below.

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


Supported events