Hello
I know how to create a pure Data Asset from this document Asset Management in Unreal Engine | Unreal Engine 5.1 Documentation, but I don’t know how to async load a blueprint generated class derived from UPrimaryDataAsset. In the Asset Manager settings, I have set “Has Blueprint Classes”, but still got a null object after cast.
UCLASS(Abstract, BlueprintType)
class ACTIONRPG_API URPGAssembly : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
/** Type of this item, set in native parent class */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Assembly)
FPrimaryAssetType AssemblyType;
/** Returns the logical name, equivalent to the primary asset id */
UFUNCTION(BlueprintCallable, Category = Item)
FString GetIdentifierString() const;
/** Overridden to use saved type */
virtual FPrimaryAssetId GetPrimaryAssetId() const override;
};
FString URPGAssembly::GetIdentifierString() const
{
return GetPrimaryAssetId().ToString();
}
FPrimaryAssetId URPGAssembly::GetPrimaryAssetId() const
{
// This is a DataAsset and not a blueprint so we can just use the raw FName
// For blueprints you need to handle stripping the _C suffix
return FPrimaryAssetId(AssemblyType, FName("BP_HS"));
}
UCLASS()
class ACTIONRPG_API URPGCharacterAssembly : public URPGAssembly
{
GENERATED_BODY()
public:
URPGCharacterAssembly()
{
AssemblyType = URPGAssetManager::CharacterAssemblyType;
}
};