Download

BlueprintCallable function called from C++, picked up in Blueprint?

I have a function which is decorated with BlueprintCallable macro. I call the function inside of a class called PickupItem.cpp like this:


UInventoryHUD* inventoryHUD = nullptr;
inventoryHUD->addSlot(ItemName);

The UInventoryHUD contains the function addSlot, the addSlot function accepts the name of an item and returns the name. Inside of blueprints, this is what I have:

3ed0bb0b7d683261905d4f7f15aa4bcdad5324d7.png

It just sets the name of the item returned to the TextBox’s text. The problem is that the blueprint function never executes. I know it executes if I have say a button clicked event, but not without an event.

So I know I need an event for the function to be executed, but how would I would I call that event from C++ and have the function pick it up?

What your are looking for is event either BlueprintImplementableEvent
or BlueprintNativeEvent.

When you call event in code it will be dispatched back to blueprint, where you can take some action s.