mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[ue4] Switched FTrackEntry to a UObject, should allow us to break it in blueprint editor
This commit is contained in:
parent
f2e364be3e
commit
05f5bbeb1e
Binary file not shown.
@ -3,7 +3,9 @@
|
||||
#define LOCTEXT_NAMESPACE "Spine"
|
||||
|
||||
void callback(spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event) {
|
||||
USpineSkeletonAnimationComponent* component = (USpineSkeletonAnimationComponent*)entry->rendererObject;
|
||||
USpineSkeletonAnimationComponent* component = (USpineSkeletonAnimationComponent*)state->rendererObject;
|
||||
|
||||
component->SpineAnimationStartEvent.Broadcast(231);
|
||||
}
|
||||
|
||||
USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () {
|
||||
@ -38,6 +40,8 @@ void USpineSkeletonAnimationComponent::CheckState () {
|
||||
skeleton = spSkeleton_create(data);
|
||||
stateData = spAnimationStateData_create(data);
|
||||
state = spAnimationState_create(stateData);
|
||||
state->rendererObject = (void*)this;
|
||||
state->listener = callback;
|
||||
}
|
||||
|
||||
lastAtlas = Atlas;
|
||||
@ -67,37 +71,45 @@ void USpineSkeletonAnimationComponent::FinishDestroy () {
|
||||
Super::FinishDestroy();
|
||||
}
|
||||
|
||||
FTrackEntry USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FString animationName, bool loop) {
|
||||
UTrackEntry USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FString animationName, bool loop) {
|
||||
CheckState();
|
||||
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
||||
spTrackEntry* entry = spAnimationState_setAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0);
|
||||
return FTrackEntry(entry);
|
||||
} else return FTrackEntry();
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
|
||||
}
|
||||
|
||||
FTrackEntry USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) {
|
||||
UTrackEntry USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) {
|
||||
CheckState();
|
||||
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
||||
spTrackEntry* entry = spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay);
|
||||
return FTrackEntry(entry);
|
||||
} else return FTrackEntry();
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
FTrackEntry USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
||||
UTrackEntry USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
||||
CheckState();
|
||||
if (state) {
|
||||
spTrackEntry* entry = spAnimationState_setEmptyAnimation(state, trackIndex, mixDuration);
|
||||
return FTrackEntry(entry);
|
||||
} else return FTrackEntry();
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
FTrackEntry USpineSkeletonAnimationComponent::AddEmptyAnimation (int trackIndex, float mixDuration, float delay) {
|
||||
UTrackEntry USpineSkeletonAnimationComponent::AddEmptyAnimation (int trackIndex, float mixDuration, float delay) {
|
||||
CheckState();
|
||||
if (state) {
|
||||
spTrackEntry* entry = spAnimationState_addEmptyAnimation(state, trackIndex, mixDuration, delay);
|
||||
return FTrackEntry(entry);
|
||||
} else return FTrackEntry();
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::ClearTracks () {
|
||||
|
||||
@ -7,17 +7,22 @@
|
||||
#include "spine/spine.h"
|
||||
#include "SpineSkeletonAnimationComponent.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct SPINEPLUGIN_API FTrackEntry {
|
||||
GENERATED_BODY ();
|
||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent), BlueprintType)
|
||||
class SPINEPLUGIN_API UTrackEntry: public UObject {
|
||||
GENERATED_BODY ()
|
||||
|
||||
public:
|
||||
|
||||
FTrackEntry (): entry(0) { }
|
||||
UTrackEntry () { }
|
||||
|
||||
FTrackEntry (spTrackEntry* entry) { this->entry = entry; }
|
||||
spTrackEntry* entry = nullptr;
|
||||
|
||||
spTrackEntry* entry;
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
int GetTrackIndex() { return entry ? entry->trackIndex : 0; }
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpineAnimationStartEvent, UTrackEntry*, entry);
|
||||
|
||||
class USpineAtlasAsset;
|
||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent))
|
||||
class SPINEPLUGIN_API USpineSkeletonAnimationComponent: public USpineSkeletonComponent {
|
||||
@ -38,16 +43,16 @@ public:
|
||||
|
||||
// Blueprint functions
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
FTrackEntry SetAnimation (int trackIndex, FString animationName, bool loop);
|
||||
UTrackEntry* SetAnimation (int trackIndex, FString animationName, bool loop);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
FTrackEntry AddAnimation (int trackIndex, FString animationName, bool loop, float delay);
|
||||
UTrackEntry* AddAnimation (int trackIndex, FString animationName, bool loop, float delay);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
FTrackEntry SetEmptyAnimation (int trackIndex, float mixDuration);
|
||||
UTrackEntry* SetEmptyAnimation (int trackIndex, float mixDuration);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
FTrackEntry AddEmptyAnimation (int trackIndex, float mixDuration, float delay);
|
||||
UTrackEntry* AddEmptyAnimation (int trackIndex, float mixDuration, float delay);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
void ClearTracks ();
|
||||
@ -55,8 +60,8 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||
void ClearTrack (int trackIndex);
|
||||
|
||||
// UFUNCTION(BlueprintImplentableEvent, category = "Components|Spine")
|
||||
// void AnimationEvent(int trackIndex, );
|
||||
UPROPERTY(BlueprintAssignable, Category = "Components|Spine")
|
||||
FSpineAnimationStartEvent AnimationStartEvent;
|
||||
|
||||
protected:
|
||||
virtual void CheckState () override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user