From f31c2985283f1d9ba8f2e1a63105feb50bd28221 Mon Sep 17 00:00:00 2001 From: badlogic Date: Thu, 1 Dec 2016 14:33:48 +0100 Subject: [PATCH] [ue4] Initial set of blueprint functions --- .../Private/SpineSkeletonComponent.cpp | 36 +++++++++++++++++++ .../SpineSkeletonRendererComponent.cpp | 3 +- .../Public/SpineSkeletonComponent.h | 21 ++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp index 27adadc19..402718a04 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp @@ -59,4 +59,40 @@ void USpineSkeletonComponent::FinishDestroy () { Super::FinishDestroy(); } +void USpineSkeletonComponent::SetAnimation (int trackIndex, FString animationName, bool loop) { + if (state) { + spAnimationState_setAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0); + } +} + +void USpineSkeletonComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) { + if (state) { + spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay); + } +} + +void USpineSkeletonComponent::SetEmptyAnimation (int trackIndex, float mixDuration) { + if (state) { + spAnimationState_setEmptyAnimation(state, trackIndex, mixDuration); + } +} + +void USpineSkeletonComponent::AddEmptyAnimation (int trackIndex, float mixDuration, float delay) { + if (state) { + spAnimationState_addAnimationByName(state, trackIndex, mixDuration, delay); + } +} + +void USpineSkeletonComponent::ClearTracks () { + if (state) { + spAnimationState_clearTracks(state); + } +} + +void USpineSkeletonComponent::ClearTrack (int trackIndex) { + if (state) { + spAnimationState_clearTrack(state, trackIndex); + } +} + #undef LOCTEXT_NAMESPACE diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp index a1ba360c6..12c3e80c5 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp @@ -40,8 +40,7 @@ void USpineSkeletonRendererComponent::TickComponent (float DeltaTime, ELevelTick pageToMaterial.Add(currPage, material); currPage = currPage->next; } - } - else { + } else { pageToMaterial.Empty(); spAtlasPage* currPage = skeleton->Atlas->GetAtlas(false)->pages; for (int i = 0; i < skeleton->Atlas->atlasPages.Num(); i++) { diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h index d08b8fcc0..d15024e64 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h @@ -31,7 +31,26 @@ public: virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; virtual void FinishDestroy () override; - + + // Blueprint functions + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void SetAnimation (int trackIndex, FString animationName, bool loop); + + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void AddAnimation (int trackIndex, FString animationName, bool loop, float delay); + + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void SetEmptyAnimation (int trackIndex, float mixDuration); + + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void AddEmptyAnimation (int trackIndex, float mixDuration, float delay); + + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void ClearTracks (); + + UFUNCTION(BlueprintCallable, Category="Components|Spine") + void ClearTrack (int trackIndex); + protected: void DisposeState();