CREATE YOUR WORLD
Scripting

UI Event

4min
zepetoscript has integrated support for the unity ui system you can use different gui components such as panels, buttons, text input box, and toggle menus to create the user interface in your world to use a unity ui elements in zepetoscript, you need to import them first unityengine ui import { slider, button } from 'unityengine ui'; then, declare the unity ui element you would like to add as a property typescript public sliderui slider; public btnui button; the declared properties are now visible and accessible in the zepetoscript inspector window open the hierarchy window and drag and drop the unity ui components into each property field in the zepetoscript inspector window with the property values assigned, you can access and manipulate them from within the script use this to add a handler for any of the control’s events eventlistener start() { this btnui onclick addlistener(() => { // add button click event console log('btnui onclick'); }); this sliderui onvaluechanged addlistener(v => { // add slider event console log(`\[${v}] sliderui onvaluechanged`); }); } play to check that the ui event is handled properly check the entire sample code ui event import { zepetoscriptbehaviour } from 'zepeto script'; import { slider, button } from 'unityengine ui'; export default class uievent extends zepetoscriptbehaviour { public sliderui slider; public btnui button; start() { this btnui onclick addlistener(() => { // add button click event console log('btnui onclick'); }); this sliderui onvaluechanged addlistener(v => { // add slider event console log(`\[${v}] sliderui onvaluechanged`); }); } } you can learn more about unity uis that zepetoscript provide by clicking the links below 📘 unity ui https //docs unity3d com/kr/current/manual/com unity ugui html https //docs unity3d com/kr/current/manual/com unity ugui html 📘 interaction components https //docs unity3d com/kr/current/manual/comp uiinteraction html https //docs unity3d com/kr/current/manual/comp uiinteraction html