0

I am creating a Component and in it I might need to call some other component's method, but I don't know in advance, which component it will be, so I guess "cc.Event" is the best candidate for my task.

When I do it this way, it won't work:

@ccclass
export default class Helloworld extends cc.Component {

    @property({ type: cc.Event })
    public event: cc.Event = new cc.Event("", true);

}

But I'd like to do it just like we have it in CCButton: event example in properties bar

How can I achieve that? I looked up in CCButton sources, I can see that it points to inspector.js, but I could not find this inspector file anywhere.

1 Answer 1

0

This is how it works.

@ccclass
export default class Helloworld extends cc.Component {
    mySuperDuperFunction(_ev, customparam) {
        cc.log("hi , i am super duper !",_ev, customparam); // log will output on debug compile.
    }
}
  1. Drag this as a component to your node
  2. Add this node to your buttons events
  3. Choose HelloWorld for the component combo
  4. Choose mySuperDuperFunction from the list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.