Hi! I’m newbee in C++ and trying to migrate from Unity3D to Unreal Engine. For creating games i need to storage data in Blueprint Classes (like ScriptingObject in Unity3D) and dynamic load them from sctipts (because i need also use them in my future plugins)
I create my UBlueprintFunctionLibrary class and named him UBlueprintDBItem and tried two advices from this and this
And in both of cases i take 0 count TArray of assets
Here is my code in first case
FReply FAssistLibModule::CollectBlueprintsButtonClicked()
{
UE_LOG(LogTemp, Warning, TEXT("COLLECTING"));
UClass* cls = TSubclassOf<class UBlueprintDBItem>();
auto Library = UObjectLibrary::CreateLibrary(cls, true, true);
Library->LoadBlueprintAssetDataFromPath(FString(TEXT("/Game/Blueprints/BlueprintDB")));
TArray<FAssetData> Assets;
Library->GetAssetDataList(Assets);
UE_LOG(LogTemp, Warning, TEXT("ASSETS: %d"), Assets.Num());
for (auto& Asset : Assets)
{
UBlueprint* bp = Cast<UBlueprint>(Asset.GetAsset());
if (bp)
{
UE_LOG(LogTemp, Warning, TEXT("CONTENT: %s"), *bp->GetName());
}
else {
UE_LOG(LogTemp, Warning, TEXT("CONTENT: %s"), *Asset.GetAsset()->GetName());
}
}
return FReply::Handled();
}
and seconds case
FReply FAssistLibModule::CollectBlueprintsButtonClicked()
{
UE_LOG(LogTemp, Warning, TEXT("COLLECTING"));
UClass* cls = TSubclassOf<class UBlueprintDBItem>();
auto Library = UObjectLibrary::CreateLibrary(cls, true, true);
Library->AddToRoot();
Library->LoadBlueprintsFromPath(FString(TEXT("/Game/Blueprints/BlueprintDB")));
TArray<UBlueprintGeneratedClass *> Assets;
Library->GetObjects<UBlueprintGeneratedClass>(Assets);
UE_LOG(LogTemp, Warning, TEXT("ASSETS: %d"), Assets.Num());
for (auto& Asset : Assets)
{
UE_LOG(LogTemp, Warning, TEXT("BP: %s"), *Asset->GetName());
}
return FReply::Handled();
}
In both cases my console log is
LogTemp:Warning: COLLECTING
LogTemp:Warning: ASSETS: 0
My problem is i dont understand how UObjectLibrary works
Thanks for any advices