I would like to support importing clothes(as SkeletalMeshes) and props(as StaticMeshes) as uasset files into game for content creators, which obviously have not been packaged with the game. Basically I am looking for a clean modding pipeline.
EDIT:
TLDR:
Is it possible to load .uasset files with StaticLoadObject()
into game and use assets from it after the game has been packaged?
Or does it only work with packaged files?
If not what function do you recommend for that purpose?
not-TLDR
Bringing in stuff does work well in the editor, using Rama's LoadObjectFromAssetPath, just by:
right clicking my asset in Content Browser
copy reference
and copy pasting the result to the path variable of the LoadObjectFromAssetPath blueprint node.
Well, I am not sure if it is going to work at runtime...
So I used my favourite search engine and put in some keywords and bumped into this.
Then I wrote some code(Blueprint Function Library):
void UFileDialogOpener::LoadFile(FString from) {
auto result = StaticLoadObject(UStaticMesh::StaticClass(), NULL, *from);
GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, "from: " + from);
if(result)GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Green, "name: " + result->GetName());
else GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Green, "no result");
auto * meSkelMesh = Cast<UStaticMesh>(result);
if(meSkelMesh)GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, meSkelMesh->GetName());
else GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, "no mesh");
}
As per the debug messages StaticLoadObject does not find anything. I tried feeding it the both of the results of righclicking my asset in Content Browser and choosing either: copy reference and copy path. Neither of them yielded any result.
Not sure where I am messing up.
Anyways, just wondering if anyone can recommend a better way of doing this(code, plugins etc)?