DateSayurin

How to use Spine. Animation.Duration modify the length of the animation using the state machine(SkeletonMecanim). I want to move the frame back to make the animation longer. Although I can modify the value of the frame and make it work, I can't modify the length of the entire animation
Here are more details of the code
public SkeletonMecanim skeletonMecanim;
public Animator animator;

protected Skeleton skeleton;
protected SkeletonData skeletonData;
protected Spine.Animation moveAnimation;

void Start()
{
skeletonMecanim = GetComponent<SkeletonMecanim>();
animator = GetComponent<Animator>();
skeleton = skeletonMecanim.skeleton;
skeletonData = skeleton.Data;

//get animation , because there are only 1 animation and only 1 timeline so i write like this
foreach (Spine.Animation animation in skeletonData.Animations)
{
moveAnimation = animation;
}

//look at this!
//This does not take effect. The length is still the original length
moveAnimation.Duration = 10;

//get TranslateTimeline
TranslateTimeline translateTimeline = null;
foreach (Timeline timeline in moveAnimation.Timelines)
{
translateTimeline = timeline as TranslateTimeline;
}

//The moving value of this frame has been successfully changed,
//but the animation length still remains unchanged
//why and how to deal with this orzzzzzzzz
translateTimeline.SetFrame(1, 10, 50, 60);



}
So what's the problem )))
DateSayurin
  • Postovi: 2

Misaki

(Moved this post to Unity from Editor since it appears to be a Unity-related question.)
Avatar
Misaki

Misaki
  • Postovi: 1152

Harald

You need to also adjust the duration of your Mecanim AnimationClip which is used in your Controller asset. Otherwise Mecanim will assume that your animation is already done at the old unmodified duration.

In case it helps: you can find the code that generates a Mecanim AnimationClip for a Spine.Animation here:
SkeletonBaker.cs : L145-L149
Avatar
Harald

Harri
  • Postovi: 4451

DateSayurin

Harald je napisao/la:You need to also adjust the duration of your Mecanim AnimationClip which is used in your Controller asset. Otherwise Mecanim will assume that your animation is already done at the old unmodified duration.

In case it helps: you can find the code that generates a Mecanim AnimationClip for a Spine.Animation here:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs#L145-L149]SkeletonBaker.cs : L145-L149
Thank you so much!! I Successfully modified the animation duration!!
It seems that I still have a lot to learn, and I know for the first time that github can be used like this.
In a word, thank you very much!!
DateSayurin
  • Postovi: 2

Harald

Thanks for your kind words, very glad it helped! :)
Avatar
Harald

Harri
  • Postovi: 4451


Natrag na Unity