i have a set a group of UDataAsset objects called UAmmoDataAsset
This is their code
USTRUCT(BlueprintType)
struct FAmmoData:public FTableRowBase
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 id;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EProjectileTypes projectileType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 damage;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<AProjectile> projectilePrefab;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cosmetic")
FName projectileName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cosmetic")
FName description;
};
UCLASS()
class CASTLEVERSUS_API UAmmoDataAsset : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, AssetRegistrySearchable)
FAmmoData ammoData;
};
in gameinstance i want to preload their FSoftObjectPath so in the game load them as required.
My problem is this
UObjectLibrary* ObjectLibrary = ObjectLibrary = UObjectLibrary::CreateLibrary(UAmmoDataAsset::StaticClass(), true, GIsEditor);
ObjectLibrary->AddToRoot();
ObjectLibrary->LoadAssetDataFromPath(TEXT("/Game/Data/AmmoCollection"));
ObjectLibrary->GetAssetDataList(assetsData);
for (int32 i = 0; i < assetsData.Num(); i++)
{
//how can i read the int32 id; from FAmmoData here?
}
i need to access to the FAmmoData id so i can sort by id the Tarray of softpath
as far as i know if i use assetsData*.GetAsset() it loads the objects, but this breaks the purpose of having them soft-referenced because they load in memory, isn’t?