Download

Async loaded material not working

...
Handle = StreamableManager.RequestAsyncLoad(SoftObjectPathA, FStreamableDelegate::CreateUObject(this, &AwindowsFunctions::afterLoading));
...

//AwindowsFunctions::afterLoading() {
	Handle->GetLoadedAssets(myObj);
	USkeletalMesh* Mesh = Cast<USkeletalMesh>(myObj[6]);
	UMaterial* Mat = Cast<UMaterial>(myObj[4]);
	if (Mat) {
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Material Loaded."));
	}
	FSkeletalMaterial SKMat = UMaterialInstanceDynamic::Create(Mat,this);
	UMaterialInstanceDynamic* ExampleMID = UMaterialInstanceDynamic::Create(Mat,this);
	GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, Mat->GetFName().ToString());
	MatA.Add(SKMat);
	MatA.Add(SKMat);
	if (Mesh) {
		theMesh = Mesh;
		theMesh->SetMaterials(MatA);
		SKMComp->SetSkeletalMesh(Mesh,false);
		SMComp->SetMaterial(0,Mat);
		UMaterialInterface *MatTest = SMComp->GetMaterial(0);

		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, MatTest->GetFullName());
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, MatTest->GetFName().ToString());

	}
...

I mounted a customed Pak file to a customed mountpoint. The Skeleton mesh loaded worked. But the material just didn’t work, no matter how. However, printing the name of it shows it had been loaded properly. I’m so confused. Pls, somebody help me…