Blueprint Reflection C++ Reference
Get name and path information about an object's Blueprint from C++ with UBPReflection.
Header: BPReflection.h · Class: UBPReflection
In Blueprints these functions describe the Blueprint that called them, because the node passes in Self. In C++, they describe whatever object you pass in, based on its class. For example outputs, see the Blueprint Reflection nodes.
| Name | Description |
|---|---|
GetCallingBlueprintName | The object's class name. |
GetCallingBlueprintPath | The Blueprint's package path, or the class path. |
GetCallingBlueprintInfo | Name and path details in one call. |
NOTE
Passing this from a C++ class describes the object's runtime class. If the object is an instance of a Blueprint subclass, you get the Blueprint, not your C++ class.
GetCallingBlueprintName
static FString UBPReflection::GetCallingBlueprintName(const UObject* WorldContextObject);| Name | Description |
|---|---|
WorldContextObject | The object to describe. |
Returns: The name of the object's class. For a Blueprint, this is the generated class name, ending in _C. Returns Unknown if WorldContextObject is null.
GetCallingBlueprintPath
static FString UBPReflection::GetCallingBlueprintPath(const UObject* WorldContextObject);| Name | Description |
|---|---|
WorldContextObject | The object to describe. |
Returns: In editor builds (WITH_EDITOR), when the object's class was generated by a Blueprint, the Blueprint's package path, like /Game/MyGame/BP_Player. Otherwise, the class's path name, like /Game/MyGame/BP_Player.BP_Player_C, or /Script/<Module>.<Class> for a native class. Returns an empty string if WorldContextObject is null.
GetCallingBlueprintInfo
static void UBPReflection::GetCallingBlueprintInfo(const UObject* WorldContextObject, FString& OutBlueprintName, FString& OutContentPath, FString& OutFullPath, FString& OutFullReferencePath);| Name | Description |
|---|---|
WorldContextObject | The object to describe. |
OutBlueprintName | Receives the Blueprint asset's name, or the class name when no Blueprint is available. |
OutContentPath | Receives the package path with /Game/ replaced by Content/. Empty when no Blueprint is available. |
OutFullPath | Receives the full package path. Empty when no Blueprint is available. |
OutFullReferencePath | Receives the Blueprint asset's object path, or the class path when no Blueprint is available. |
The Blueprint details are only available in editor builds, for classes generated by a Blueprint. If WorldContextObject is null, OutBlueprintName is Unknown and the other outputs are empty.
Example
#include "BPReflection.h"
void AMyActor::LogIdentity() const
{
FString BlueprintName, ContentPath, FullPath, ReferencePath;
UBPReflection::GetCallingBlueprintInfo(this, BlueprintName, ContentPath, FullPath, ReferencePath);
UE_LOG(LogTemp, Log, TEXT("%s (%s)"), *UBPReflection::GetCallingBlueprintName(this), *FullPath);
}