[ue4] Only show preview animation and skin in editor viewports.

This commit is contained in:
badlogic 2019-03-08 16:37:22 +01:00
parent d55724a1b5
commit 79e4f9ca69
4 changed files with 18 additions and 16 deletions

View File

@ -89,23 +89,25 @@ void USpineSkeletonAnimationComponent::BeginPlay() {
void USpineSkeletonAnimationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) {
Super::Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
InternalTick(DeltaTime);
InternalTick(DeltaTime, true, TickType == LEVELTICK_ViewportsOnly);
}
void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDelegates) {
void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDelegates, bool Preview) {
CheckState();
if (state && bAutoPlaying) {
if (lastPreviewAnimation != PreviewAnimation) {
if (PreviewAnimation != "") SetAnimation(0, PreviewAnimation, true);
else SetEmptyAnimation(0, 0);
lastPreviewAnimation = PreviewAnimation;
}
if (Preview) {
if (lastPreviewAnimation != PreviewAnimation) {
if (PreviewAnimation != "") SetAnimation(0, PreviewAnimation, true);
else SetEmptyAnimation(0, 0);
lastPreviewAnimation = PreviewAnimation;
}
if (lastPreviewSkin != PreviewSkin) {
if (PreviewSkin != "") SetSkin(PreviewSkin);
else SetSkin("default");
lastPreviewSkin = PreviewSkin;
if (lastPreviewSkin != PreviewSkin) {
if (PreviewSkin != "") SetSkin(PreviewSkin);
else SetSkin("default");
lastPreviewSkin = PreviewSkin;
}
}
state->update(DeltaTime);
state->apply(*skeleton);

View File

@ -258,7 +258,7 @@ void USpineSkeletonComponent::TickComponent (float DeltaTime, ELevelTick TickTyp
InternalTick(DeltaTime);
}
void USpineSkeletonComponent::InternalTick(float DeltaTime, bool CallDelegates) {
void USpineSkeletonComponent::InternalTick(float DeltaTime, bool CallDelegates, bool Preview) {
CheckState();
if (skeleton) {

View File

@ -260,10 +260,10 @@ public:
UPROPERTY(BlueprintAssignable, Category="Components|Spine|Animation")
FSpineAnimationDisposeDelegate AnimationDispose;
UPROPERTY(Transient, EditAnywhere, Category=Spine)
UPROPERTY(EditAnywhere, Category=Spine)
FString PreviewAnimation;
UPROPERTY(Transient, EditAnywhere, Category=Spine)
UPROPERTY(EditAnywhere, Category=Spine)
FString PreviewSkin;
// used in C event callback. Needs to be public as we can't call
@ -271,7 +271,7 @@ public:
void GCTrackEntry(UTrackEntry* entry) { trackEntries.Remove(entry); }
protected:
virtual void CheckState () override;
virtual void InternalTick(float DeltaTime, bool CallDelegates = true) override;
virtual void InternalTick(float DeltaTime, bool CallDelegates = true, bool Preview = false) override;
virtual void DisposeState () override;
spine::AnimationState* state;

View File

@ -133,7 +133,7 @@ public:
protected:
virtual void CheckState ();
virtual void InternalTick(float DeltaTime, bool CallDelegates = true);
virtual void InternalTick(float DeltaTime, bool CallDelegates = true, bool Preview = false);
virtual void DisposeState ();
spine::Skeleton* skeleton;