Skip to content

Delegates

How do I add an event dispatcher?

Declare it with @ue.udelegate, as a method with no body. Its parameters are what bound callbacks receive.

@ue.uclass
class Door(ue.Actor):
    @ue.udelegate
    def on_opened(self, by: ue.Actor | None, damage: int) -> None: ...

    def open(self, by: ue.Actor) -> None:
        self.on_opened.broadcast(by, 0)

The class gets a multicast delegate property that is BlueprintAssignable and BlueprintCallable: Blueprints bind to it with Bind Event and can call it.

From Python:

def on_door_opened(by: ue.Actor | None, damage: int) -> None:
    ue.log("door opened")


door.on_opened.add(on_door_opened)

The type checker sees self.on_opened as ue.MulticastDelegate[...] with the method's parameter types, so add() callbacks and broadcast() arguments are checked.

In a script bound to a Blueprint (@ue.script), @ue.udelegate creates a Blueprint event dispatcher.