Why is my C++ Event not visible in Blueprint?
Hi everyone,i'm trying to make the "OnMouseClick" event visible to my blueprint. The problem is that,it is only visible,when i create a new blueprint in the editor based on the interface containing the event. But if i instead,extends that interface in a C++ class and then use an object of that class in a blueprint,the event does not appear in the editor's list.
My interface: #pragma once
How i extend the class:
Now,in the HUD blueprint,i created an object "UHUDCButton",but the event does not appear in the list.
What am i doing wrong? Thanks in advance.
Oh sorry i forgot ^^' Event functions works only locally because explointing function override, if you no inside the class you can' override function so you can't use that. In order to make events that works anywhere you need to create delegate. Delegate decleration needs to be outside of class
Now you need to create property with "BlueprintAssignable" to which you will be able to bind functions, use class name which you used in delegate
This alone should let you do external event binds in blueprint :) now in C++ binding is a little bitty more complex:
First argument is object in which function is located (use "this" if you want to bind inside the class), 2nd argument is pointer to function that will be called on event. Use BindDymanic() if you use non-multicast delegate, also keep in mind ha binded function arguments need to fit delegate arguments
Now to raise the event you need to call:
On which all currently binded functions will be called, if you use delegate with arguments you need to input arguments in to Broadcast():
Thats all! ^^ And i still hink you need to add those events inside of base class insted of interface, thats how most classes work in engine
IF you wan some example of delegate use, try looking on engine source code, AActor class got lot of them so search for Actor.h and Actor.cpp
Follow this question
Once you sign in you will be able to subscribe for any updates here