I have been trying to wrap my head around AssetManager and the best way to use it to optimize my game for a data-driven structure. I have the following code:
In WeaponAsset:
...
UPROPERTY(EditAnywhere, Category="Abilities", meta=(AssetBundles="Stats"))
TSoftObjectPtr<UAbilitySet> AbilitySet;
...
In UWeaponInventoryComponent::LoadWeapon
...
const FPrimaryAssetId AssetId(FPrimaryAssetType("Weapon"), AssetName);
const TArray<FName> Bundles = TArray<FName>{"Stats"};
const FStreamableDelegate Delegate = FStreamableDelegate::CreateUObject(
this, &UWeaponInventoryComponent::OnWeaponToAddLoaded, AssetId);
AssetManager->LoadPrimaryAsset(AssetId, Bundles, Delegate);
...
In UWeaponInventoryComponent::OnWeaponToAddLoaded
...
const TObjectPtr<UWeaponAsset> WeaponData = AssetManager->GetPrimaryAssetObject<
UWeaponAsset>(AssetId);
if(!WeaponData->AbilitySet)
{
UE_LOG(LogTemp, Error, TEXT("UWeaponInventoryComponent::OnWeaponLoaded: WeaponData.AbilitySet is null"));
return;
}
...
The code works, however in order to test that only the contents of the Data Asset labeled Stats are being loaded, I change the Bundles array to only contain an unused Asset Bundle tag, such as “TestBundle”. The issue I am encountering is that even after changing the Bundles array, I do not receive a nullptr and the code continues as normal. This leads me to believe that Bundles is being completely ignored and the entirety of the Asset’s contents are being loaded. Am I missing something about the Asset Manager and the functions that I am using regarding it?