How to access Data Asset C++ class using Asset Manager in BP

Hi there, how do I use a C++ Data Asset in a Blueprint?

I created some Data Asset subclasses from this info:

So I have a C++ class (see code below).

I added this Asset Base Class to the “Asset Manager” section in Project settings. My understanding is it will load and make these available for runtime.

I made a couple missions (content browser → right-click → misc → data asset → select Mission base class → fill in data)

I’m now trying to list all these Mission assets in my game’s main menu using a level blueprint. I’m stuck because I can’t “Cast To Mission”

Get Asset Registry → Get Assets by Class (Class Name = “Mission”) → For each → Get Asset → ???

How do I use a C++ Data Asset class in a Blueprint? I’m not finding a path from UObject to UMission. Is there a better way?

Mission.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "MissionPlan.h"
#include "MissionObjective.h"

#include "Mission.generated.h"

/**
 * A mission on the main menu
 */
UCLASS()
class FPSGAME_API UMission : public UDataAsset
{
	GENERATED_BODY()
	
public:

	UPROPERTY(EditDefaultsOnly)
		FString Title;

	UPROPERTY(EditDefaultsOnly)
		FString Summary;

	UPROPERTY(EditDefaultsOnly)
		UTexture2D* Photo;

	UPROPERTY(EditDefaultsOnly)
		TArray<FMissionObjective> RequiredMissionObjectives;

	UPROPERTY(EditDefaultsOnly)
		TArray<class UMissionPlan*> MissionPlans;

	UFUNCTION(BlueprintCallable)  // Iterate plans
		TArray<FMissionObjective> AllPossibleMissionObjectives();
};

Bump! I burried my own question answering others :slight_smile:

To cast to a class in blueprints, it needs to be marked as BlueprintType. I had to change the UCLASS macro declaration to this:

UCLASS(BlueprintType)
class FPSGAME_API UMissionPlan : public UDataAsset

I also had to add BlueprintReadOnly to the UPROPERTYs to be able to access the properties

Really helpful!