hello,
I used RuntimeStaticMeshImporter plugin import static mesh,and set the mesh to a already existing StaticMeshComponent,
these code is called on in BeginPlay function of BWMeshComponentsArrActor
TArray<UStaticMeshComponent*> aa;
this->GetComponents(aa);
for (int32 b = 0; b < aa.Num(); b++)
{
UStaticMeshComponent* a = aa[b];
FString RelFbxFileFullPath = TEXT("E:/UEProject/Resource/FbxFile/onlyfbx/DevonRexCat.fbx");
FString ThisFbxFile = RelFbxFileFullPath;
FSTMIFilePathData FbxPathStruct111;
FbxPathStruct111.FilePath = ThisFbxFile;
TArray<FSTMIObjectData> FbxDatas;
URuntimeStaticMeshImporterBFL::LoadFbxFile(ThisFbxFile, FbxPathStruct111, FbxDatas);
FString FbxName = FPaths::GetBaseFilename(ThisFbxFile);
for (int32 i = 0; i < FbxDatas.Num(); i++)
{
UStaticMeshComponent* paddle1 = a;
UProceduralMeshComponent* pMeshComponent;
URuntimeStaticMeshImporterBFL::CreatePMCFromData(FbxDatas[i], pMeshComponent);
URuntimeStaticMeshImporterBFL::PopulateStaticMeshFromPMC(pMeshComponent, paddle1);
/*FString MatInsResPath = TEXT("/Game/FreeBasicMaterial/Materials/Examples/MI_EasyDefault_Inst1.MI_EasyDefault_Inst1");
UMaterialInstance* DynamicMaterial = (UMaterialInstance*)LoadObject<UMaterialInterface>(nullptr, *MatInsResPath);
paddle1->SetMaterial(0, DynamicMaterial);*/
FRotator NewRotation(0, 0, -90);
paddle1->SetRelativeRotation(NewRotation);
//paddle1->CastShadow = 1;
}
}
the paddle1 is the already existing StaticMeshComponent, but the mesh can’t cast Shadow,like this
but if there ism’t material on the StaticMeshComponent, the mesh can cast Shadow