mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
[ue4] Fixed up PR #1251.
This commit is contained in:
commit
8fe981cfe1
Binary file not shown.
Binary file not shown.
@ -78,6 +78,7 @@ USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () {
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
bTickInEditor = true;
|
||||
bAutoActivate = true;
|
||||
bAutoPlaying = true;
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::BeginPlay() {
|
||||
@ -94,7 +95,7 @@ void USpineSkeletonAnimationComponent::TickComponent(float DeltaTime, ELevelTick
|
||||
void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDelegates) {
|
||||
CheckState();
|
||||
|
||||
if (state) {
|
||||
if (state && bAutoPlaying) {
|
||||
state->update(DeltaTime);
|
||||
state->apply(*skeleton);
|
||||
if (CallDelegates) BeforeUpdateWorldTransform.Broadcast(this);
|
||||
@ -160,6 +161,36 @@ void USpineSkeletonAnimationComponent::FinishDestroy () {
|
||||
Super::FinishDestroy();
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::SetAutoPlay(bool bInAutoPlays)
|
||||
{
|
||||
bAutoPlaying = bInAutoPlays;
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::SetPlaybackTime(float InPlaybackTime, bool bCallDelegates)
|
||||
{
|
||||
CheckState();
|
||||
|
||||
if (state && state->getCurrent(0)) {
|
||||
spine::Animation* CurrentAnimation = state->getCurrent(0)->getAnimation();
|
||||
const float CurrentTime = state->getCurrent(0)->getTrackTime();
|
||||
InPlaybackTime = FMath::Clamp(InPlaybackTime, 0.0f, CurrentAnimation->getDuration());
|
||||
const float DeltaTime = InPlaybackTime - CurrentTime;
|
||||
state->update(DeltaTime);
|
||||
state->apply(*skeleton);
|
||||
|
||||
//Call delegates and perform the world transform
|
||||
if (bCallDelegates)
|
||||
{
|
||||
BeforeUpdateWorldTransform.Broadcast(this);
|
||||
}
|
||||
skeleton->updateWorldTransform();
|
||||
if (bCallDelegates)
|
||||
{
|
||||
AfterUpdateWorldTransform.Broadcast(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::SetTimeScale(float timeScale) {
|
||||
CheckState();
|
||||
if (state) state->setTimeScale(timeScale);
|
||||
|
||||
@ -331,4 +331,4 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
clipper.clipEnd();
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@ -194,6 +194,16 @@ public:
|
||||
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
virtual void FinishDestroy () override;
|
||||
|
||||
//Added functions for manual configuration
|
||||
|
||||
/* Manages if this skeleton should update automatically or is paused. */
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine|Animation")
|
||||
void SetAutoPlay(bool bInAutoPlays);
|
||||
|
||||
/* Directly set the time of the current animation, will clamp to animation range. */
|
||||
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Animation")
|
||||
void SetPlaybackTime(float InPlaybackTime, bool bCallDelegates = true);
|
||||
|
||||
// Blueprint functions
|
||||
UFUNCTION(BlueprintCallable, Category="Components|Spine|Animation")
|
||||
@ -255,4 +265,9 @@ protected:
|
||||
// in transit within a blueprint
|
||||
UPROPERTY()
|
||||
TSet<UTrackEntry*> trackEntries;
|
||||
|
||||
private:
|
||||
/* If the animation should update automatically. */
|
||||
UPROPERTY()
|
||||
bool bAutoPlaying;
|
||||
};
|
||||
|
||||
@ -86,9 +86,9 @@ public:
|
||||
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
||||
FLinearColor Color = FLinearColor(1, 1, 1, 1);
|
||||
|
||||
/** Whether to generate collision geometry for the skeleton, or not. */
|
||||
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
||||
bool bCreateCollision;
|
||||
/** Whether to generate collision geometry for the skeleton, or not. */
|
||||
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
||||
bool bCreateCollision;
|
||||
|
||||
virtual void FinishDestroy() override;
|
||||
|
||||
@ -99,4 +99,4 @@ protected:
|
||||
|
||||
spine::Vector<float> worldVertices;
|
||||
spine::SkeletonClipping clipper;
|
||||
};
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user