I started working on the spine a few days ago and was looking for ways to control the duration of animation in addition to using time scaling.
After researching, I saw that I could follow the example of the SpineGauce scene and manually update the playback timepoint.
public void SetGaugePercent (float percent)
{
if (skeletonRenderer == null) return;
var skeleton = skeletonRenderer.skeleton; if (skeleton == null) return;
fillAnimation.Animation.Apply(skeleton, 0, percent, false, null, 1f, MixBlend.Setup, MixDirection.In);
skeleton.UpdateWorldTransform();
}
With that, I could make the animation run at a different time than the original, without using the timescale.
The example code below shows my attempt
attackAnimation = skeletonRenderer.skeleton.Data.FindAnimation("attack");
//The original animation have a duration of 1s so lets say the new duration have 10s
attackAnimation.Duration = 10f;
public void Update()
{
if (m_renderer != null )
{
elapsedTime += Time.deltaTime;
float percent = elapsedTime / attackAnimation.Duration;
attackAnimation.Apply(m_renderer.skeleton, 0, percent, false, null, 1f, MixBlend.Setup, MixDirection.In);
m_renderer.skeleton.UpdateWorldTransform();
}
}
However, the animation events are not triggered and in the SpineGauce example, the list of events is passed as null.
So I would like to know if there is a way to access the events to pass them in the Apply method because I couldn't find any way to access this list.