[ue4] Fixed segfault in SpineSkeletonDataAsset. Added PreviewAnimation and PreviewSkin to SpineSkeletonAnimationComponent. Enter the name of an animation or skin and it will be previewed live in the editor view. Use an empty string to reset the animation or skin.

This commit is contained in:
badlogic 2019-03-06 16:54:47 +01:00
parent 4ba46d76e8
commit cef191f6c6
3 changed files with 21 additions and 0 deletions

View File

@ -96,6 +96,17 @@ void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDe
CheckState(); CheckState();
if (state && bAutoPlaying) { if (state && bAutoPlaying) {
if (lastPreviewAnimation != PreviewAnimation) {
if (PreviewAnimation != "") SetAnimation(0, TCHAR_TO_UTF8(*PreviewAnimation), true);
else SetEmptyAnimation(0, 0);
lastPreviewAnimation = PreviewAnimation;
}
if (lastPreviewSkin != PreviewSkin) {
if (PreviewSkin != "") SetSkin(TCHAR_TO_UTF8(*PreviewSkin));
else SetSkin("default");
lastPreviewSkin = PreviewSkin;
}
state->update(DeltaTime); state->update(DeltaTime);
state->apply(*skeleton); state->apply(*skeleton);
if (CallDelegates) BeforeUpdateWorldTransform.Broadcast(this); if (CallDelegates) BeforeUpdateWorldTransform.Broadcast(this);

View File

@ -128,6 +128,7 @@ public:
void USpineSkeletonDataAsset::LoadInfo() { void USpineSkeletonDataAsset::LoadInfo() {
#if WITH_EDITORONLY_DATA #if WITH_EDITORONLY_DATA
int dataLen = rawData.Num(); int dataLen = rawData.Num();
if (dataLen == 0) return;
NullAttachmentLoader loader; NullAttachmentLoader loader;
SkeletonData* skeletonData = nullptr; SkeletonData* skeletonData = nullptr;
if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) { if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) {

View File

@ -259,6 +259,12 @@ public:
UPROPERTY(BlueprintAssignable, Category="Components|Spine|Animation") UPROPERTY(BlueprintAssignable, Category="Components|Spine|Animation")
FSpineAnimationDisposeDelegate AnimationDispose; FSpineAnimationDisposeDelegate AnimationDispose;
UPROPERTY(Transient, EditAnywhere)
FString PreviewAnimation;
UPROPERTY(Transient, EditAnywhere)
FString PreviewSkin;
// used in C event callback. Needs to be public as we can't call // used in C event callback. Needs to be public as we can't call
// protected methods from plain old C function. // protected methods from plain old C function.
@ -279,4 +285,7 @@ private:
/* If the animation should update automatically. */ /* If the animation should update automatically. */
UPROPERTY() UPROPERTY()
bool bAutoPlaying; bool bAutoPlaying;
FString lastPreviewAnimation;
FString lastPreviewSkin;
}; };