diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp index c078910ae..5547ae43f 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp @@ -42,7 +42,7 @@ USpineSkeletonComponent::USpineSkeletonComponent () { bAutoActivate = true; } -bool USpineSkeletonComponent::SetSkin(const FString& skinName) { +bool USpineSkeletonComponent::SetSkin (const FString skinName) { CheckState(); if (skeleton) { Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName)); @@ -53,7 +53,24 @@ bool USpineSkeletonComponent::SetSkin(const FString& skinName) { else return false; } -bool USpineSkeletonComponent::SetAttachment (const FString& slotName, const FString& attachmentName) { +void USpineSkeletonComponent::GetSkins (TArray &Skins) { + CheckState(); + if (skeleton) { + for (size_t i = 0, n = skeleton->getData()->getSkins().size(); i < n; i++) { + Skins.Add(skeleton->getData()->getSkins()[i]->getName().buffer()); + } + } +} + +bool USpineSkeletonComponent::HasSkin (const FString skinName) { + CheckState(); + if (skeleton) { + return skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*skinName)) != nullptr; + } + return false; +} + +bool USpineSkeletonComponent::SetAttachment (const FString slotName, const FString attachmentName) { CheckState(); if (skeleton) { if (!skeleton->getAttachment(TCHAR_TO_UTF8(*slotName), TCHAR_TO_UTF8(*attachmentName))) return false; @@ -127,7 +144,7 @@ void USpineSkeletonComponent::SetBoneWorldPosition (const FString& BoneName, con } } -void USpineSkeletonComponent::UpdateWorldTransform() { +void USpineSkeletonComponent::UpdateWorldTransform () { CheckState(); if (skeleton) { skeleton->updateWorldTransform(); @@ -154,24 +171,24 @@ void USpineSkeletonComponent::SetScaleX (float scaleX) { if (skeleton) skeleton->setScaleX(scaleX); } -float USpineSkeletonComponent::GetScaleX() { +float USpineSkeletonComponent::GetScaleX () { CheckState(); if (skeleton) return skeleton->getScaleX(); return 1; } -void USpineSkeletonComponent::SetScaleY(float scaleY) { +void USpineSkeletonComponent::SetScaleY (float scaleY) { CheckState(); if (skeleton) skeleton->setScaleY(scaleY); } -float USpineSkeletonComponent::GetScaleY() { +float USpineSkeletonComponent::GetScaleY () { CheckState(); if (skeleton) return skeleton->getScaleY(); return 1; } -void USpineSkeletonComponent::GetBones(TArray &Bones) { +void USpineSkeletonComponent::GetBones (TArray &Bones) { CheckState(); if (skeleton) { for (size_t i = 0, n = skeleton->getBones().size(); i < n; i++) { @@ -180,6 +197,58 @@ void USpineSkeletonComponent::GetBones(TArray &Bones) { } } +bool USpineSkeletonComponent::HasBone (const FString BoneName) { + CheckState(); + if (skeleton) { + return skeleton->getData()->findBone(TCHAR_TO_UTF8(*BoneName)) != nullptr; + } + return false; +} + +void USpineSkeletonComponent::GetSlots (TArray &Slots) { + CheckState(); + if (skeleton) { + for (size_t i = 0, n = skeleton->getSlots().size(); i < n; i++) { + Slots.Add(skeleton->getSlots()[i]->getData().getName().buffer()); + } + } +} + +bool USpineSkeletonComponent::HasSlot (const FString SlotName) { + CheckState(); + if (skeleton) { + return skeleton->getData()->findSlot(TCHAR_TO_UTF8(*SlotName)) != nullptr; + } + return false; +} + +void USpineSkeletonComponent::GetAnimations(TArray &Animations) { + CheckState(); + if (skeleton) { + for (size_t i = 0, n = skeleton->getData()->getAnimations().size(); i < n; i++) { + Animations.Add(skeleton->getData()->getAnimations()[i]->getName().buffer()); + } + } +} + +bool USpineSkeletonComponent::HasAnimation(FString AnimationName) { + CheckState(); + if (skeleton) { + return skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*AnimationName)) != nullptr; + } + return false; +} + +float USpineSkeletonComponent::GetAnimationDuration(FString AnimationName) { + CheckState(); + if (skeleton) { + Animation *animation = skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*AnimationName)); + if (animation == nullptr) return 0; + else return animation->getDuration(); + } + return 0; +} + void USpineSkeletonComponent::BeginPlay() { Super::BeginPlay(); } diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h index 303d11efc..eac35678a 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonAnimationComponent.h @@ -90,7 +90,7 @@ public: UFUNCTION(BlueprintCallable, Category="Components|Spine|TrackEntry") bool GetLoop () { return entry ? entry->getLoop() : false; } UFUNCTION(BlueprintCallable, Category="Components|Spine|TrackEntry") - void SetLoop(bool loop) { if (entry) entry->setLoop(loop); } + void SetLoop(bool loop) { if (entry) entry->setLoop(loop); } UFUNCTION(BlueprintCallable, Category="Components|Spine|TrackEntry") float GetEventThreshold () { return entry ? entry->getEventThreshold() : 0; } @@ -157,6 +157,15 @@ public: UFUNCTION(BlueprintCallable, Category="Components|Spine|TrackEntry") void SetMixDuration(float mixDuration) { if (entry) entry->setMixDuration(mixDuration); } + UFUNCTION(BlueprintCallable, Category = "Components|Spine|TrackEntry") + FString getAnimationName() { return entry ? entry->getAnimation()->getName().buffer() : ""; } + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|TrackEntry") + float getAnimationDuration() { return entry ? entry->getAnimation()->getDuration(): 0; } + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|TrackEntry") + float isValidAnimation() { return entry != nullptr; } + UPROPERTY(BlueprintAssignable, Category = "Components|Spine|TrackEntry") FSpineAnimationStartDelegate AnimationStart; diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h index 45a494579..376a8a93c 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h @@ -53,12 +53,18 @@ public: USpineSkeletonDataAsset* SkeletonData; spine::Skeleton* GetSkeleton () { return skeleton; }; + + UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton") + void GetSkins(TArray &Skins); UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") - bool SetSkin (const FString& SkinName); + bool SetSkin (const FString SkinName); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + bool HasSkin(const FString SkinName); UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") - bool SetAttachment (const FString& slotName, const FString& attachmentName); + bool SetAttachment (const FString slotName, const FString attachmentName); UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") FTransform GetBoneWorldTransform (const FString& BoneName); @@ -92,6 +98,24 @@ public: UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton") void GetBones(TArray &Bones); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + bool HasBone(const FString BoneName); + + UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton") + void GetSlots(TArray &Slots); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + bool HasSlot(const FString SlotName); + + UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton") + void GetAnimations(TArray &Animations); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + bool HasAnimation(FString AnimationName); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + float GetAnimationDuration(FString AnimationName); UPROPERTY(BlueprintAssignable, Category = "Components|Spine|Skeleton") FSpineBeforeUpdateWorldTransformDelegate BeforeUpdateWorldTransform;