LoadObject failed ,Not path problem

(I don’t know why i can’t upload image,and sorry about my bad English.)

I created a class,and add a member function call LoadMesh(),

UObject* ALoadTest::LoadMesh()

	UObject* obj = LoadObject<UStaticMesh>(NULL, TEXT("StaticMesh'/Game/FirstPerson/Meshes/FirstPersonProjectileMesh.FirstPersonProjectileMesh'"), NULL, LOAD_None, NULL);

	return obj;

then,i derive a blueprint form class, I add a staticmeshcomponent in blueprint. I called the LoadMesh() function after beginplay node,so i get the UObject resource and cast to staticmesh.then call statimeshcomponent member function setstaticmesh() to set staticmesh. And it works in PIE,but when i package out through projectlauncher.it does’t work.

Before I ask question,i did a lot of tests,And find some Interesting .

  1. When I drag the staticmesh into the scene I want to loaded. and package out through projectlauncher.it work.it’s look like this staticmesh must exist in scene ,so when package it will be packaged together.

2.I have a lot of resources,If I specify resource one by one with in blueprint,When it’s packed,It’s normally large.but throuth above method package,It’s Unnormal small when packed .I believe more when your resource is not referenced,and through projectlanucher to package, these resource won’t be packaged in together.But my way is through the path.

3.Ues normally way to package, it work,and paks size look right .

so I know roughly what the problem is, but I don’t know how to solve it. somebody konw?

1 Like

If it works in editor but not in the packaged game check that the asset you trying to load is actually packaged. If it has no references filtered out when packaging. Go to project settings->packaging and add a directory to cook manually.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.