alternative approach to constructor helpers in order to set the default hand mesh as it won't causes annoying ue pop-up cdo messages

This commit is contained in:
Mamadou Babaei
2023-03-28 18:29:27 +02:00
parent 9f5bb2d97e
commit 4e3fa930e5
2 changed files with 17 additions and 6 deletions
@@ -206,11 +206,7 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec
bRight = true;
bHiddenInGameIfNoGloveDetected = false;
const FString SkeletalMeshPath{Pimpl->GetDefaultMeshPath()};
const ConstructorHelpers::FObjectFinder<USkeletalMesh> SkeletalMeshFinder{*SkeletalMeshPath};
ensureAlwaysMsgf(SkeletalMeshFinder.Succeeded() && SkeletalMeshFinder.Object,
TEXT("Failed to load the skeletal mesh: '%s'"), *SkeletalMeshPath);
Super::SetSkeletalMesh(SkeletalMeshFinder.Object, true);
Super::SetSkeletalMesh(nullptr, true);
bBackendInitialized = false;
Glove = nullptr;
@@ -234,6 +230,16 @@ void USGVirtualHandComponent::SetAnimClass(UClass* NewClass)
Super::SetAnimClass(NewClass);
}
void USGVirtualHandComponent::PostInitProperties()
{
Super::PostInitProperties();
if (!Pimpl->IsUsingUserMesh())
{
Pimpl->SetDefaultMesh();
}
}
#if WITH_EDITOR
void USGVirtualHandComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
@@ -488,7 +494,10 @@ USkeletalMesh* USGVirtualHandComponent::FImpl::LoadDefaultMesh() const
Cast<USkeletalMesh>(StaticLoadObject(USkeletalMesh::StaticClass(), nullptr, *DefaultMeshPath))
};
ensureAlwaysMsgf(DefaultMesh, TEXT("Failed to load the skeletal mesh: '%s'"), *DefaultMeshPath);
if (!IsValid(DefaultMesh))
{
SGLOG_WARNING(FString::Printf(TEXT("Failed to load the default skeletal mesh: '%s'"), *DefaultMeshPath));
}
return DefaultMesh;
}
@@ -116,6 +116,8 @@ public:
public:
virtual void SetAnimClass(class UClass* NewClass) override;
virtual void PostInitProperties() override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif /* WITH_EDITOR */