Hi there, how do I use a C++ Data Asset in a Blueprint?
I created some Data Asset subclasses from this info:
- UE4 C++ Data Assets | Level Plus Game Studio
- WTF Is? Data Asset in Unreal Engine 4 ( UE4 ) - YouTube
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();
};