Using multicast delegates on a c++ class that is not a UClass
I have declared a multicast delegate in the following fashion in header file
It shows me the following compilation error in .generated.cpp
The above problems still remains but I found a workaround. If I use DECLARE_DELEGATE or DECLARE_EVENT it works on a non UClass class. It allows me to broadcast the event. The problem that I am having now is listening the event in my Actor sub class.
I tried using AddRaw(this, &MyActorSubclass::MyFunction) - but it fails with 'no such method definition for AddRaw'. I dont understand why this fails to compile?? (MyFunction is not a UFUNCTION). Can someone please let me know the correct way of achieving this?
I also tried AddSP() but unfortunately TSharedFromThis is not allowed on Actor sub classes. So cant use this.
EDIT: Updated the question with my most recent findings.
There are a few issues. You shouldn't prefix your class with U if you are not UObject derived. Since you are naming it UMyClassComponent, then I am assuming you have a UObject based class derived from some UInsertHereComponent. Your error Z_Construct etc, just tells you that you are missing UCLASS / GENERATED_UCLASS_BODY etc. To make delegate work with this setup use AddUObject .
If you have a plain class, not UObject derived, say FMySomething, then the following will work:
Hope this helps.
answered Oct 27 '14 at 09:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here