mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
[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:
parent
4ba46d76e8
commit
cef191f6c6
@ -96,6 +96,17 @@ void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDe
|
||||
CheckState();
|
||||
|
||||
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->apply(*skeleton);
|
||||
if (CallDelegates) BeforeUpdateWorldTransform.Broadcast(this);
|
||||
|
||||
@ -128,6 +128,7 @@ public:
|
||||
void USpineSkeletonDataAsset::LoadInfo() {
|
||||
#if WITH_EDITORONLY_DATA
|
||||
int dataLen = rawData.Num();
|
||||
if (dataLen == 0) return;
|
||||
NullAttachmentLoader loader;
|
||||
SkeletonData* skeletonData = nullptr;
|
||||
if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) {
|
||||
|
||||
@ -259,6 +259,12 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category="Components|Spine|Animation")
|
||||
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
|
||||
// protected methods from plain old C function.
|
||||
@ -279,4 +285,7 @@ private:
|
||||
/* If the animation should update automatically. */
|
||||
UPROPERTY()
|
||||
bool bAutoPlaying;
|
||||
|
||||
FString lastPreviewAnimation;
|
||||
FString lastPreviewSkin;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user