diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp index 38d36134..38c6e9c9 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp @@ -206,11 +206,7 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec bRight = true; bHiddenInGameIfNoGloveDetected = false; - const FString SkeletalMeshPath{Pimpl->GetDefaultMeshPath()}; - const ConstructorHelpers::FObjectFinder 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(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; } diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h index 6ccb82ed..ca4f200a 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h @@ -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 */