noobsee
noobsee

Reputation: 972

How to use CustomEventData in Button component Cocos Creator 3.5.0 Typescript

In the Button component we have CustomEventData. In my understanding the purpose it to send extra parameter when user tap the button.

enter image description here

I have tried to use it like this:

use_powerUp(par: string){
    console.log("MapScreenManager::use_powerUp() = ", par);
}

The Button will call the function and I thought the CustomEventData will be automatically become 1 parameter that will fill the par parameter. But turns out it didn’t.

Can anyone guide me how to properly use the CustomEventData?

I am using Cocos Creator 3.5.0 with Typescript.

Upvotes: 1

Views: 1030

Answers (1)

noobsee
noobsee

Reputation: 972

I just found the solution, it's very simple

use_powerUp(event: Event, CustomEventData)
{

}

Upvotes: 2

Related Questions