How to set the UI properties for a mesh using C++?

Hi , I am trying to do this is C++, Please correct me If I am doing something not right.

What I tying is :

void AMyTestClass::InitPickup(EItemType ItemType_In, FText Name_In, FText UIPrefix_In, UStaticMesh* StaticMesh_In)
{
	Init(ItemType_In, Name_In);
	UI_Prefix = UIPrefix_In;
	if (IsValid(StaticMesh))
	{
		StaticMesh->SetStaticMesh(StaticMesh_In);
	}
}

Thank You

If you get an error post it here

I am not getting any error but the mesh information is not updating by assigning the static mesh.
I think I am doing something not correct or missing… currently debugging the issue :yawning_face:

Does it work in blueprint? have you set breakpoints in VS to check if SetStaticMesh is reached and what it does after?

yes it worked in Blueprints and now its working in C++ too, I were doing it wrong under init function, Now its working fine :slightly_smiling_face: