Hello! So i have a quest giver component attached to an npc character in the scene. in the quest giver, i have a quest data variable declared like so “UPROPERTY(EditInstanceOnly, BlueprintReadWrite)
FDataTableRowHandle QuestData;”. In the scene i set the details of the quest data. i am trying to display a widget that makes use of the data table which was created based off FQuestDetails struct. in the widget class, i declare my variable "UPROPERTY(EditInstanceOnly, BlueprintReadWrite, meta = (ExposeOnSpawn = “true”))
FQuestDetails QuestDetails; " and have this function
void UW_QuestGiver::NativePreConstruct()
{
Super::NativePreConstruct();
if (TXT_QuestName)
TXT_QuestName->SetText(QuestDetails.QuestName);
if (TXT_QuestDescription)
TXT_QuestDescription->SetText(QuestDetails.LogDescription);
if (TXT_StageDescription)
TXT_StageDescription->SetText(QuestDetails.Stages[0].Description);
}
In questgiver, i try to display the widget like this
void UQuestGiver::DisplayQuest()
{
if (QuestData.DataTable != nullptr && !QuestData.RowName.IsNone())
{
FString ContextString(TEXT("Quest Context"));
FQuestDetails* DataRow = QuestData.DataTable->FindRow<FQuestDetails>(QuestData.RowName, ContextString);
if (DataRow != nullptr)
{
UW_QuestGiver* QuestGiverWidget = CreateWidget<UW_QuestGiver>(GetWorld(), UW_QuestGiver::StaticClass());
if (QuestGiverWidget != nullptr)
{
QuestGiverWidget->QuestDetails = *DataRow;
QuestGiverWidget->AddToViewport(9999);
}
}
}
}