So, you've constructed some custom UCLASS
intended for use inside UE4. But how do you instantiate them? Objects in UE4 are reference-counted and memory-managed, so you should not allocate them directly using the C++ keyword new
. Instead, you'll have to use a function called ConstructObject
to instantiate your UObject
derivative. ConstructObject
doesn't just take the C++ class of the object you are creating, it also requires a Blueprint class derivative of the C++ class (a UClass*
reference). A UClass*
reference is just a pointer to a Blueprint.
How do we instantiate an instance of a particular Blueprint from C++ code? C++ code does not, and should not, know concrete UCLASS
names, since these names are created and edited in the UE4 Editor, which you can only access after compilation. We need a way to somehow hand back the Blueprint class name to instantiate to the C++ code.
The way we do this is by having the UE4 programmer select the UClass
that...