Hi there,
I’m trying to bind a function to [SkeletalMesh OnMeshChanged][1], but I’m having trouble getting my function to bind. My usecase for this function is to be able to update another SkeletalMeshComponent that needs to grab the new skeletal mesh every time the Character’s skeletal mesh is changed.
Here’s what I have in my .h file:
public:
// Editor related code
#if WITH_EDITOR
UFUNCTION()
void SetToonSkeletalMesh();
#endif
And here’s what’s in my .cpp file (in my constructor):
#if WITH_EDITOR
this->GetMesh()->SkeletalMesh->GetOnMeshChanged().AddUObject(this, &ATdpCharacter::SetToonSkeletalMesh);
#endif
and further down in the file, is the implementation of that method
#if WITH_EDITOR
void ATdpCharacter::SetToonSkeletalMesh()
{
ToonOutlineComp->SetSkeletalMesh(this->GetMesh()->SkeletalMesh);
}
#endif
This compiles, but the editor crashes immediately on launch. I’m familiar with AddDynamic, but that particular function does not seem to be available here. I wasn’t sure which of these to use (Add, AddUObject, AddUFunction, etc.)
Does anyone have any pointers on how I can attach my method to the OnMeshChanged event?