Creating a class-variable in C++ for use in BP

Class varable is UClass* as this is class identifier in reflection system, it’s also UObject on it self. When you start engine each class will have UClass created for them use to identify them. There also TSubclassOf which you use like this:

TSubclassOf<AActor> ActorClass;

This is same as UClass* but it a special template which limits selection of classes in editor to specific subclass so this above will show only actor classes in editor.

In C++ you can get UClass* of any class in C++ by using StaticClass() static function like this AMyActor::StaticClass() and from object using GetClass() function.

5 Likes