From 1534558e3851182e0aed857d28e66041365b7388 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 4 Jun 2024 10:40:30 +0200 Subject: [PATCH] [ue] Closes #2537, null renderer object if UTrackEntry is destroyed. --- .../Private/SpineSkeletonAnimationComponent.cpp | 7 +++++++ .../SpinePlugin/Public/SpineSkeletonAnimationComponent.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp index 428c5b9c5..c8b22b69f 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp @@ -82,6 +82,13 @@ void USpineSkeletonAnimationComponent::BeginPlay() { trackEntries.Empty(); } +void UTrackEntry::BeginDestroy() { + if (entry) { + entry->setRendererObject(nullptr); + } + Super::BeginDestroy(); +} + void USpineSkeletonAnimationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::Super::TickComponent(DeltaTime, TickType, ThisTickFunction); diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h index be4af1461..6975b65c5 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h @@ -219,6 +219,8 @@ public: UPROPERTY(BlueprintAssignable, Category = "Components|Spine|TrackEntry") FSpineAnimationDisposeDelegate AnimationDispose; + virtual void BeginDestroy() override; + protected: spine::TrackEntry *entry = nullptr; };