mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +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) {
|
||||
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 () {
|
||||
@ -71,43 +77,43 @@ void USpineSkeletonAnimationComponent::FinishDestroy () {
|
||||
Super::FinishDestroy();
|
||||
}
|
||||
|
||||
UTrackEntry 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);
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||
uEntry->SetTrackEntry(entry);
|
||||
return uEntry;
|
||||
} 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();
|
||||
if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
|
||||
spTrackEntry* entry = spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay);
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||
uEntry->SetTrackEntry(entry);
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
UTrackEntry USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
||||
UTrackEntry* USpineSkeletonAnimationComponent::SetEmptyAnimation (int trackIndex, float mixDuration) {
|
||||
CheckState();
|
||||
if (state) {
|
||||
spTrackEntry* entry = spAnimationState_setEmptyAnimation(state, trackIndex, mixDuration);
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||
uEntry->SetTrackEntry(entry);
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
UTrackEntry 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);
|
||||
UTrackEntry* uEnty = NewObject<UTrackEntry>();
|
||||
uEntry->entry = entry;
|
||||
UTrackEntry* uEntry = NewObject<UTrackEntry>();
|
||||
uEntry->SetTrackEntry(entry);
|
||||
return uEntry;
|
||||
} else return NewObject<UTrackEntry>();
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
#include "spine/spine.h"
|
||||
#include "SpineSkeletonAnimationComponent.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpineAnimationStartEvent, UTrackEntry*, entry);
|
||||
|
||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent), BlueprintType)
|
||||
class SPINEPLUGIN_API UTrackEntry: public UObject {
|
||||
GENERATED_BODY ()
|
||||
@ -16,12 +18,18 @@ public:
|
||||
UTrackEntry () { }
|
||||
|
||||
spTrackEntry* entry = nullptr;
|
||||
|
||||
void SetTrackEntry(spTrackEntry* entry) {
|
||||
this->entry = entry;
|
||||
entry->rendererObject = (void*)this;
|
||||
}
|
||||
|
||||
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;
|
||||
UCLASS(ClassGroup=(Spine), meta=(BlueprintSpawnableComponent))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user