How do I send Custom Data to a buttons click function?

Preferably in Typescript :slight_smile:

For example I have a button which has an event that calls this function:

loadScene(sceneToLoad)
    {
        console.log("Button clicked"+sceneToLoad);
        cc.director.loadScene(sceneToLoad,null);
    }

However, how can I populate the ‘sceneToLoad’ string argument. I thought it would be as simple as just adding it to the customData parameter in the button component in the editor…but that didnt work.

The custom data will be the second argument to the event handler…

buttonPressHandler(e: cc.Event.EventTouch, customEventData: string) {
    cc.log(customEventData);
}

Great. Thank You!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.