I try to grab all blueprint assets that has special actor component attached. Code as Follow:
FAssetRegistryModule& AssetRegModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AllBlueprintAssetData;
if (AssetRegModule.Get().GetAssetsByClass(UBlueprint::StaticClass()->GetFName(), AllBlueprintAssetData))
{
for (FAssetData& AssetData : AllBlueprintAssetData)
{
UBlueprint* BP = Cast<UBlueprint>(AssetData.GetAsset());
if (BP && !BP->GeneratedClass->HasAnyClassFlags(CLASS_Abstract))
{
UObject* UObj = NewObject<UObject>(GetTransientPackage(), BP->GeneratedClass);
AActor* Actor = Cast<AActor>(UObj);
if (Actor)
{
TArray<UActorComponent*> RSComponents = Actor->GetComponentsByClass(URSComponent::StaticClass());
for (UActorComponent* Acomponent : RTSComponents)
{
Cast<URSComponent>(Acomponent)->RefreshRSConfig();
}
}
}
}
}
But no working, NewObject always return the class default setting blueprint.(If attach a new component to blueprint, that component will missing, but actually it existed when i open this blueprint in editor).