UCLASS([specifier, specifier, …], [meta(key=value, key=value, …)])
class ClassName : ParentName
{
GENERATED_UCLASS_BODY()
}
I know this is standard declare form of UE4’s class derived from UObject.The offcial’s documentation say : These are used to create the UClass for the class being declared, which can be thought of as the engine’s specialized representation of the class. Also, the GENERATED_UCLASS_BODY() macro must be placed at the very beginning of the class body. Can I understand if I define a class drived from UObject,at the same time a UClass which is representation for my class while be created by the UE4 ?
Yes, UnrealHeaderTool (UH), before compilation os parseing headers in search of all UMACROS() (which are only used for that, in reality they are empty macros that does nothing durring compilation), when it finds those macros it read it specifiers and reads information below it, class/varable/function name, function arguments, general information about the thing below. Based on that and specifiers in macro, UHT generates extra header files (For GENERATED_UCLASS_BODY()) and cpp file which contain registering code, which adds stuff that he find in to reflection system and creates objects for each of them (UClass, UFunction, UProperty), which later can be used to identify them in the code. Most commonly used is UClass as C++ can’t point classes in varable
So in short, yes, UClass is generated for each UObject class with UCLASS() (and if im not mistaken you need to place that macro in UObjects)
I have one more doubt, please clarify which one of what follows is right. For each class derived from UObject, 1. a separete class derived from UClass is generated or 2. an instance of UClass is generated?