Skip to content

Instantly share code, notes, and snippets.

@rdeioris
Created April 11, 2020 09:41
Show Gist options
  • Save rdeioris/fcbe3ff74a44608c75b1fe6661cd8f86 to your computer and use it in GitHub Desktop.
Save rdeioris/fcbe3ff74a44608c75b1fe6661cd8f86 to your computer and use it in GitHub Desktop.
How to extract Unreal Engine Blueprint comments via c++
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AssetData;
AssetRegistryModule.Get().GetAssetsByClass(UBlueprint::StaticClass()->GetFName(), AssetData, true);
for (FAssetData& Asset : AssetData)
{
if (Asset.ObjectPath.ToString().StartsWith("/Game/"))
{
UE_LOG(LogTemp, Log, TEXT("Found Asset: %s %s %s"), *Asset.AssetName.ToString(), *Asset.AssetClass.ToString(), *Asset.ObjectPath.ToString());
UBlueprint* Blueprint = Cast<UBlueprint>(Asset.GetAsset());
if (!Blueprint)
{
UE_LOG(LogTemp, Error, TEXT("Unable to load asset %s"), *Asset.ObjectPath.ToString());
continue;
}
for (UEdGraph* Graph : Blueprint->FunctionGraphs)
{
TArray<UEdGraphNode_Comment*> Nodes;
Graph->GetNodesOfClass<UEdGraphNode_Comment>(Nodes);
for (UEdGraphNode_Comment* Node : Nodes)
{
UE_LOG(LogTemp, Log, TEXT("Found comment for %s:%s: %s"), *Asset.ObjectPath.ToString(), *Graph->GetName(), *Node->NodeComment);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment