Converting Blueprint Structs¶
In this part, we are giong to convert the FQuestInfo BP Struct to C++
Rename FQuestInfo to FQuestInfo_Deprecated
Create new C++ class. Choose Show All Classes -> Object to create a UObject. Name it QuestInfo.
In QuestInfo.h change UCLASS to USTRUCT, removed inheritance of UOBject, change class to struct and change UQuestInfo to FQuestInfo
UCLASS()
struct BLUEPRINTSTOCPP_API FQuestInfo
USTRUCT(BlueprintType)
class BLUEPRINTSTOCPP_API FQuestInfo
Add the body of QuestInfo struct.
USTRUCT(BlueprintType)
struct BLUEPRINTSTOCPP_API FQuestInfo
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName QuestId;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Progress;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProgressTotal;
};
In my case UE4 would crash and so require launching again.
Include QuestInfo.h in QuestManager.h
#include "QuestInfo.h"
Add protected UPROPERTY to
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FQuestInfo> QuestList;
Rename variable QuestList to QuestList_Deprecated
In BP_QuestManager Blueprint -> Class Defaults, replace QuestList with the new one. Unforunately, we’ll have to copy and paste each item over.
Find all references to QuestList_Deprecated and fix them.
GetQuest is slightly more tricky it’s interface expect return of QuestInfo_Deprecated.
We could either migrate all uses of GetQuest or we can convert our C++ QuestInfo to QuestInfo_Deprecated.
Now go through all other references of QuestList_Deprecated and replace with QuestList.
Where the graph is large and uses get on QuestList_Deprecated, we could always be lazy and replace it with GetQuests that we created.