prerequisite
Confirm that the resources will be packaged together into the package file.
If they cannot be packaged into the package file, you need to add an additional package directory in the project settings.
Two ways to get resource information by path
Blueprint (simple)
c++ (slightly complicated)
-
Add dependent modules
-
Add reference path
-
Load resource information (TArray)
-
The blueprint call and set
the FunLib_GetStaticMeshByContentPath method is actually a method of loading static resources on the c++ side by inputting the file path
// TEXT("/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder")
bool UJGF_FunLib::FunLib_GetStaticMeshByContentPath( const FString& contentPath, UStaticMesh* & mesh)
{
mesh = LoadObject<UStaticMesh>(nullptr, *contentPath);
if (mesh)
{
return true;
}
return false;
}