The most critical implementation of Runtime is uobject, which is the base class of all engine-level and game-level objects.
Uobject implements dynamic creation, persistence, scripting, memory management, and lifecycle control.
---------------------------
About dynamic creation
---------------------------
Creating an object using a class name is a dynamic creation.
The unrealengine4 process is:
Fstringclassreference xxxxclassname;
|
Tsubclassof <XXXX> xxxxclass;
|
XXXX * xxxxobject ;;
Find the runtime type information through the class name, and then create an object through the runtime type information.
Ufield, ustruct, uclass, uproperty, ufunction, and uenum are the data structures used to construct runtime information. For details, see runtime/coreuobject/public/uobject/class. h.
At this time, a problem arises: how to build these runtime type information?
In unrealengine4, each class corresponds to a XXXX. generated. H, which contains the macro definition code for constructing runtime type information. This XXXX. gengerated. H is generated through unrealheadertool (UHT.
UHT is generated by parsing the keyword uclass, ustruct, uproperty, ufunction, and uenum in each header file.
Unrealengine4 uobject (1)