Hi all…
I have a C++ class derived from UObject that implements various functionality. I’ll just call it UClass-A. In that header file, I had defined two custom delegates that were to be used in this class and another, I’ll call it UClass-B. All this was working fine. The other class could see and use the delegate types just fine.
However, I wanted to move the delegate definitions into a separate header file where the sole purpose of that header was to contain custom delegate definitions to be used across multiple classes in the underlying C++ framework.
I used Unreal to create a new C++ class based on UObject called CustomDelegates.h just for the purpose of having a location to define all my delegates. Once Unreal was done generating everything, I moved the delegate definitions from UMyClass and into this CustomDelegates.H file.
In CustomDelegates.H, I removed all the class reference stuff out of the header file just so that it was a pretty empty header with only the custom delegate definitions. I DID leave in the #includes that Unreal generated for me.
I went into UClass-A and UClass-B and ensured that both the header files had the proper include specifying CustomDelegates.H.
Not sure if this would make a difference but could be part of the problem I’m seeing, my inheritance looks like this…
UClass-A : UObject
UClass-B : AActor
And again, when I had the delegate definitions in UClass-A header, everything worked fine.
However, now that I moved the delegate definitions into CustomDelegates.H, UClass-B can’t find the delegates. I don’t get any type of error saying that the compiler can’t find CustomDelegates.h, rather, it just says that it can’t find the definition for my delegates.
No compile errors against UClass-A, only UClass-B. Seems odd that both classes could find and use these delegates when they were defined at the top of UClass-A.
Anyone have any thoughts on why this might be happening?
EDIT
So, I opened up CustomDelegates.h. I put the class definition back in the header. It sits below the delegate definitions and is as basic as can be…
UCLASS()
class MYPLUGIN_API CustomDelegates : public UObject
{
GENERATED_BODY()
};
After putting this back in the header… Compiles great…
Does anyone know why that would need to be in there?