I was reading about Structures and USTRUCT() and all makes sense but I just couldn’t find it anywhere on where and how to declare them.
Is the structure created in a separate dedicated .h file or can I just create it in any of my .h files?
Can the structure be created inside my class definition (i.e. inside the class itself) or does it have to go on top of it?
In some examples I saw the structure example contain the GENERATED_USTRUCT_BODY() macro, I think this means it was created using the ‘add code to project’ from inside UE4 and then choosing a USTRUCT type but I can’t figure out how to add it from the ‘add code to project’. In other examples the structure example didn’t contain the GENERATED_USTRUCT_BODY() and was just part of an existing class .h file. Is the GENERATED_USTRUCT_BODY() required or not?
So how do I go with creating a simple structure from scratch?
Of course you can put it in separate header file or put it in your class header file. It’s not something UE-specific. It’s C++ basics.
You can use simple c++ structs in your classes like you always do. But UStruct is not like that, its not a struct. UStruct is a basis of UClass, not visa versa. So correct way to use it is to create a UStruct definition in header file (same as UClass or separate) and use it as a member of this type in your UClass.
yes providing the link was no help at all as it didn’t answer any of my questions either, thank you for finally having an answer that seemed to be no where else. +1