“How do you create a UStruct?” Surely that’s easy. Why am I even asking? BECAUSE IT REFUSES TO COMPILE.
USTRUCT requires GENERATED_USTRUCT_BODY(). GENERATED_USTRUCT_BODY() requires [whatever].generated.h. [whatever].generated.h apparently doesn’t get made until you compile a USTRUCT, WHICH DOESN’T HAPPEN WITHOUT GENERATED_USTRUCT_BODY().
I know it’s possible. I’ve managed to do it twice before. But for the life of me, I CAN’T REMEMBER HOW.
Also try taking away MYPROJECT_API. I’ve never seen it used anywhere in the engine and I don’t know but don’t think it should be used like that. Also you don’t need to specify public for structs the default accessibility is public for structs including USTRUCTS.
never seen MYPROJECT_API? It automatically adds that (or rather the equivalent, based on the project name) when you create a class from the editor.
The missing ; is because I missed it when selecting. Also, as note: the code above came from one of the two times I did manage it (minus the “FMyStruct.generated.h”). Change the name of the struct and you get what I’d be looking at when it was failing.
And yet, somehow I just managed it a third time. This is magical behavior. Code should not be magical.
Never seen the API macro used in UE4 code anywhere. You probably shouldn’t have it there. Also UCLASS’s require the generated.h not USTRUCTS, I suspect this is what’s causing you the issue.
Okay to be clear because I think i can be easily misunderstood, when I say never saw the API macro in UE4 code anywhere I mean, not used for structs. It is used for classes of course.