Hello dear Community!
I have copypasted my own source files I wrote outside of Unreal into the "private" (for cpp-files) and the "public" (for my header files) folders of an unreal-C++-Project, so I can include my own custom classes in my unreal source files.
It works as it should, but I want to use my own enums, that are obviously defined in my own non-Unreal-specific Files, as UEnums, so I have to modify them there with Unreal-specific Macros.
Will Unreal Header Tool incorporate my own Files or only the ones I created from the Unreal Editor? And do I need to write a "...generated.h"-include in my own custom headers I wrote outside of Unreal?
Thank you so much in advance!
I did this:
- first I added a generated.h. My File is named like "File.h", and I added a generated.h-include in it like this:
#include "File.generated.h"
Of course as the last include, as it should be.
- Then I added the Unreal-Macros to the enum. It went from this:
enum MyEnum {
FIRST_ENTRY,
SECOND_ENTRY
};
to this:
UENUM(BlueprintType, Category="Enums")
enum MyEnum {
FIRST_ENTRY UMETA(DisplayName="First Entry"),
SECOND_ENTRY UMETA(DisplayName="Second Entry")
};
- Then I tried to incorporate a variable with this Enum type as a UProperty in one of my Unreal-Classes like this:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TEnumAsByte<MyEnum> EnumVariable;
Sadly I get an Error:
"Error: Expected the name of a previously defined enum"
Of course I included the Header File with my Enum before, so this cannot be the reason I guess.