mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-23 02:06:46 +08:00
[ue4] Trying to get events working on UTrackEntry wrappers
This commit is contained in:
parent
704a3f0d4f
commit
08db67ba1c
Binary file not shown.
@ -5,7 +5,13 @@
|
|||||||
void callback(spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event) {
|
void callback(spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event) {
|
||||||
USpineSkeletonAnimationComponent* component = (USpineSkeletonAnimationComponent*)state->rendererObject;
|
USpineSkeletonAnimationComponent* component = (USpineSkeletonAnimationComponent*)state->rendererObject;
|
||||||
|
|
||||||
component->SpineAnimationStartEvent.Broadcast(231);
|
if (type == SP_ANIMATION_START) {
|
||||||
|
if (entry->rendererObject) {
|
||||||
|
UTrackEntry* uEntry = (UTrackEntry*)entry->rendererObject;
|
||||||
|
component->AnimationStartEvent.Broadcast(uEntry);
|
||||||
|
uEntry->AnimationStartEvent.Broadcast(uEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () {
|
USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () {
|
||||||
@ -71,43 +77,43 @@ void USpineSkeletonAnimationComponent::FinishDestroy () {
|
|||||||
Super::FinishDestroy();
|
Super::FinishDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
UTrackEntry USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FString animationName, bool loop) {
|
UTrackEntry* USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FString animationName, bool loop) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
||||||
spTrackEntry* entry = spAnimationState_setAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0);
|
spTrackEntry* entry = spAnimationState_setAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0);
|
||||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||||
uEntry->entry = entry;
|
uEntry->SetTrackEntry(entry);
|
||||||
return uEntry;
|
return uEntry;
|
||||||
} else return NewObject<UTrackEntry>();
|
} else return NewObject<UTrackEntry>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UTrackEntry USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) {
|
UTrackEntry* USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
||||||
spTrackEntry* entry = spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay);
|
spTrackEntry* entry = spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay);
|
||||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||||
uEntry->entry = entry;
|
uEntry->SetTrackEntry(entry);
|
||||||
return uEntry;
|
return uEntry;
|
||||||
} else return NewObject<UTrackEntry>();
|
} else return NewObject<UTrackEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
UTrackEntry USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
UTrackEntry* USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (state) {
|
if (state) {
|
||||||
spTrackEntry* entry = spAnimationState_setEmptyAnimation(state, trackIndex, mixDuration);
|
spTrackEntry* entry = spAnimationState_setEmptyAnimation(state, trackIndex, mixDuration);
|
||||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||||
uEntry->entry = entry;
|
uEntry->SetTrackEntry(entry);
|
||||||
return uEntry;
|
return uEntry;
|
||||||
} else return NewObject<UTrackEntry>();
|
} else return NewObject<UTrackEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
UTrackEntry USpineSkeletonAnimationComponent::AddEmptyAnimation (int trackIndex, float mixDuration, float delay) {
|
UTrackEntry* USpineSkeletonAnimationComponent::AddEmptyAnimation (int trackIndex, float mixDuration, float delay) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (state) {
|
if (state) {
|
||||||
spTrackEntry* entry = spAnimationState_addEmptyAnimation(state, trackIndex, mixDuration, delay);
|
spTrackEntry* entry = spAnimationState_addEmptyAnimation(state, trackIndex, mixDuration, delay);
|
||||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||||
uEntry->entry = entry;
|
uEntry->SetTrackEntry(entry);
|
||||||
return uEntry;
|
return uEntry;
|
||||||
} else return NewObject<UTrackEntry>();
|
} else return NewObject<UTrackEntry>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
#include "spine/spine.h"
|
#include "spine/spine.h"
|
||||||
#include "SpineSkeletonAnimationComponent.generated.h"
|
#include "SpineSkeletonAnimationComponent.generated.h"
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpineAnimationStartEvent, UTrackEntry*, entry);
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent), BlueprintType)
|
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent), BlueprintType)
|
||||||
class SPINEPLUGIN_API UTrackEntry: public UObject {
|
class SPINEPLUGIN_API UTrackEntry: public UObject {
|
||||||
GENERATED_BODY ()
|
GENERATED_BODY ()
|
||||||
@ -17,11 +19,17 @@ public:
|
|||||||
|
|
||||||
spTrackEntry* entry = nullptr;
|
spTrackEntry* entry = nullptr;
|
||||||
|
|
||||||
|
void SetTrackEntry(spTrackEntry* entry) {
|
||||||
|
this->entry = entry;
|
||||||
|
entry->rendererObject = (void*)this;
|
||||||
|
}
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
UFUNCTION(BlueprintCallable, Category="Components|Spine")
|
||||||
int GetTrackIndex() { return entry ? entry->trackIndex : 0; }
|
int GetTrackIndex() { return entry ? entry->trackIndex : 0; }
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpineAnimationStartEvent, UTrackEntry*, entry);
|
UPROPERTY(BlueprintAssignable, Category = "Components|Spine")
|
||||||
|
FSpineAnimationStartEvent AnimationStartEvent;
|
||||||
|
};
|
||||||
|
|
||||||
class USpineAtlasAsset;
|
class USpineAtlasAsset;
|
||||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user