Hello,
I m trying to write a tool to help our artists mass edit some Blueprint Assets in the editor. I have created a very basic plugin (Editor Standalone Window) and I figured out how to get a list of all my asset in a specific folder, but I m stuck when it gets to editing components in those assets.
Here is my code so far :
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); TArray<FAssetData> AssetData; FARFilter Filter; Filter.ClassNames.Add(UBlueprint::StaticClass()->GetFName()); Filter.bRecursivePaths = true; Filter.bRecursiveClasses = true; Filter.PackagePaths.Add(FName(*SubPath)); bool isSuccess = AssetRegistryModule.Get().GetAssets(Filter, AssetData); UE_LOG(LogTemp, Display, TEXT("Search success : %s"), (isSuccess ? TEXT("True") : TEXT("False"))); for (FAssetData asset : AssetData) { UBlueprint* assetBP = Cast<UBlueprint>(asset.GetAsset()); if (assetBP->GeneratedClass->IsChildOf(AActor::StaticClass())) { TSubclassOf<AActor> actorClass = *assetBP->GeneratedClass; if (actorClass != nullptr) { AActor* actor = actorClass->GetDefaultObject<AActor>(); if (actor != nullptr) { UE_LOG(LogTemp, Display, TEXT("actor OK %s"), *actor->GetFullName()); TArray<UActorComponent *> children = actor->GetComponentsByClass(UActorComponent::StaticClass()); UE_LOG(LogTemp, Display, TEXT("Children %i"), children.Num()); } } } } This give me a proper list of assets but actor->GetComponentsByClass always gives me an empty array, I also tried to get actor->RootComponent but it is always null.
The assets I m trying to load are Actors with a bunch of USceneComponent in it and some UStaticMeshComponent attached to those. My ultimate goal is to edit some values in the rendering of those static mesh.
(Sorry if I m unclear English is not my native language).