At the moment I’m trying static load object;
URRUserWidget* ButtonBlueprint = Cast<URRUserWidget>(StaticLoadObject(URRUserWidget::StaticClass(), NULL, *Address));
This doesn’t work. Static constructerhelper functions wouldn’t be a good way to do it, because this can’t be in a constructor.
Does anyone know how to do this?
EDIT:
It looks as if the way to do it would be to make a UObjectLibrary and load it with the blueprint data using the paths. However, for some reason the data won’t load into the object library. This is what I’ve done to load it;
TArray<FString> WidgetPaths;
if (QuestionFile.ParseIntoArray(&WidgetPaths, TEXT("%"), true) > 0)
{
Questions = UObjectLibrary::CreateLibrary(URRUserWidget::StaticClass(), true, true);
Questions->AddToRoot();
Questions->LoadBlueprintAssetDataFromPaths(WidgetPaths);
int32 AssetCount = Questions->GetAssetDataCount();
UE_LOG(RRQuery, Warning, TEXT("Assets loaded in the Questions Library: %d"), AssetCount);
}
The log is showing that its always empty…
EDIT:
Progress!
I ditched the UObjectLibrary idea as I couldnt get it to read in to the library. And went back to using static load but also using FStringAssetReference and ResolveObject;
FStringAssetReference Widget = (*Address);
StaticLoadObject(UObject::StaticClass(), NULL, *Widget.ToString());
UObject* Resolved = Widget.ResolveObject();
UBlueprint* WidgetBP = Cast<UBlueprint>(Resolved);
if (WidgetBP->GeneratedClass->IsChildOf(URRUserWidget::StaticClass()))
{
return *(WidgetBP->GeneratedClass);
}
else return NULL;
However, it breaks on the return. All the data looks right, but it breaks to “return OwningGameInstance” in world.h. My owning game instance appears to be NULL. What this has to do with the price of tomatoes, I have no idea…