Search code examples
c++unreal-engine4unreal-blueprint

What is the c++ equivalent to BP's Class Reference?


I am converting BP to C++ and the variable in question is a Class Reference;

What is the C++ equivalent?

TSubclassOf? Type* -> StaticClass()?

I know I am overthinking this.

enter image description here


Solution

  • The equivelent would be TSubclassOf however to get a reference to a specific class you would use ClassName::StaticClass() so for example if you wanted a drop down that allowed for all Pawn types but defaulted to MyGameCharacter the code would be:

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    TSubclassOf<APawn> PawnType;
    
    void MyClassConstructor()
    {
        PawnType = MyGameCharacter::StaticClass();
    }