In part with if I’m just trying to know, does my list of meshes include ObjMesh. And that’s reason why also I can check NameID of this object, but when I try to use FString ObjName = obj->GetName(); and then to move the mouse, Unreal crashes and shows me this:
The obj is result from RayCast(), but if I use GetComponent(), obj has to be UPrimitiveComponent * type. Maybe I don’t understand something, because I’m not pro, but I can’t find way how I can get Mesh name from UPrimitiveComponent *?
If you want to get a mesh from actor, you’ll have to cast to that actor class, and either have that component be public, of create a function in the actor class that will return the needed mesh.
As for UPrimitiveComponent, you can cast it to the class you need,
UStaticMeshComponent* StaticMesh = Cast<UStaticMeshComponent>(Hit->GetComponent());
if (IsValid(StaticMesh))
{
// your code here
}
So, I tried your way, and added this lineGEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, MeshName.ToString());, which prints MeshName to screen, when I move the mouse, MeshName here is FName MeshName = Cast<UStaticMeshComponent>(RayCast().GetComponent())->GetStaticMesh()->GetBodySetupName();. But now it gives me only BodySetup message on every object I look at. Maybe you understood me incorrectly, because I need this name(for example):
I think what you want to do is instead of FName MeshName = Cast<UStaticMeshComponent>(RayCast().GetComponent())->GetStaticMesh()->GetBodySetupName(); is:
That should give you the name of the instance of the mesh you used, so in this case it would return something like Banker_Lamp_2_1 or something like that, then you could crop or get a substring of that to get the Static Mesh name