Lost references to static meshes in BP actor


I have a bunch of blueprint classes that are buildings. Dozens of static meshes are collected for each building, the problem is that the references to the meshes themselves are lost. Is there any way to make each component automatically find its corresponding mesh? The same problem with textures, when importing all the textures were lost for some reason

Can you give more information about what happened?

I don’t fully understand what’s going on or what you may have done to get here.

Of course. I have a set of assets prepared for UE. Assets represent buildings. Buildings are modular, imported as blueprint actors, which contain many static components. These static components should link to the corresponding static meshes (their names are exactly the same), but the links do not work. That’s why I see emptiness in the blueprint window (picture in topic) and in viewport . I can simply import the meshes, but then they will need to be separated from each other, in addition, the textures will still be missing from the materials (because the texture references in the materials also do not work). I didn’t change anything in the file path, so I don’t understand why the links don’t work. I can fix all this manually, but it will take a lot of time, since each building contains dozens of meshes, and each material contains dozens of textures. The question is, can I tell Unreal where to load textures and meshes from so UE automatically find?


1 Like

Thanks for clearing it up.

The textures are the root cause. Because they are β€œinvalid”, the material isn’t compiling. Because the material isn’t compiling, the static mesh isn’t forming. The static mesh is therefore INVALID, and unreal unassigns it from the meshes.

This is what I think, anyway. Not one-hundred percent. Can you fix the textures in the parent materials?

(If you are also asking if there’s a way for Unreal to automatically re-assign the static meshes to the components, I don’t think so.)

(I’d also ZIP your project whenever it’s in an acceptable state, so if something bad happens, you can just pivot back to an older version.)

This did not solve the problem, unfortunately.

.h

#pragma once

#include "CoreMinimal.h"
#include "Kismemphasized textet/BlueprintFunctionLibrary.h"
#include "StatMeshLibrary.generated.h"

class UStaticMeshComponent;

/**
 * 
 */
UCLASS()
class YOURPROJ_API UStatMeshLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	UFUNCTION(BlueprintCallable)
	static void SynchronizeStaticMesh(UPARAM(ref) UStaticMeshComponent* &smc, FString meshPath);
};

.cpp

void UStatMeshLibrary::SynchronizeStaticMesh(UPARAM(ref) UStaticMeshComponent* &smc, FString meshPath)
{			
	FString FindString = FPaths::Combine(TEXT("/Game"), meshPath, smc->GetName() + "." + smc->GetName()); 
	if (FindString.Len() > 0) {		
		UStaticMesh* StaticMesh = LoadObject<UStaticMesh>(nullptr, *FindString);				
		if (StaticMesh != nullptr) {
			smc->SetStaticMesh(StaticMesh);			
		}				
	}
}


Usage:

Use the mesh path if your static meshes are in a directory deeper than /Game