• Unity
  • Can I get events time before playing animation?

  • Изменено
Related Discussions
...

I am able to get event name and parameters before the animation starts.
How can I get the time or frame number of the event ?

You can iterate over all timelines of an animation and check if it's an http://esotericsoftware.com/spine-api-reference#EventTimeline. Then you can iterate over all Events in the EventTimeline.

The following code is not tested, but should basically describe what you need:

Spine.Animation animation = ...;
foreach (var timeline in animation.Timelines) {
   var eventTimeline = timeline as Spine.EventTimeline;
   if (eventTimeline != null) {
      foreach (Spine.Event ev in eventTimeline.Events) {
         Debug.Log(string.Format("time:{0} string:{1}", ev.Time, ev.String));
      }
   }
}