Hi! I’m creating custom event system and want to create component property like ClickEvents in Button component.
There in Button component, I will get list of components and their methods after I set Node. Values of dropdown depends of Node value;
So, I’m going to make it in way like this, but I can understand how it works in Button component.
import { _decorator, Component, Enum } from 'cc';
const { ccclass, property, executeInEditMode, type } = _decorator;
enum Emitters {
GLOBAL = 'global',
LOCAL = 'local',
}
enum GlobalEvents {
EVENT1 = 'event1',
}
enum LocalEvents {
EVENT2 = 'event2',
}
@ccclass
class Listener {
@property({ type: Enum(Emitters) })
emitters = Emitters.GLOBAL; // For example: I'm planning to set it to Emitters.LOCAL
@property({
type: ??? // should be dynamically change when I set emitters value
})
event; // For example: I'm planning to set it to LocalEvents.EVENT2 because I set emitters to Emitters.LOCAL
}
@ccclass('EventListener')
export class EventListener extends Component {
@property([Listener])
listeners: Listener[] = [];
start() {}
update(deltaTime: number) {}
}
So, my question is how I can get this behaviour?
Thanks!