Hi all,
I’m having an hard time understanding how to properly use DataAssets in C++. I’m trying to configure a custom WorldSubsystem in it’s initialize method.
Theese are the steps I’ve done so far:
- Create a C++ class which inherits from UPrimaryDataAsset (which contains only 1 field)
UCLASS(BlueprintType)
class MYPROJECT_API UTimeSubsystemConfigDataAsset : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Calendar")
int32 DaysInMonth = 2;
}
-
Created a Blueprint DataAsset which has my C++ class as Parent;
-
Configured AssetManager in Project Settings->DataAsset manager
-
Trying to load the dataAsset to configure my subsystem (Relevant code)
if(UAssetManager* AssetManager = UAssetManager::GetIfValid())
{
FPrimaryAssetType Type = FPrimaryAssetType(FName("TimeSubsystem"));
TArray<FAssetData> Assets;
AssetManager->GetPrimaryAssetDataList(Type, Assets);
if(Assets.Num() > 0)
GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, TEXT("DATA ASSET FOUND"));
}
The AssetManager is initializated and valid but does not populate the Assets array.
Digging into debug I found that the GetPrimaryAssetDataList return false due to the line code in the image:
Am I doing it wrong? I feel like something is missing but I cannot see what’s wrong. The documentation is not so well documented (especially for non english speakers, but that’s my problem).
Any help would be really appreciated
Thanks
Luca