44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BF
|
|
{
|
|
[ExecuteInEditMode]
|
|
[DisallowMultipleComponent]
|
|
public class UISpineHelper : MonoBehaviour
|
|
{
|
|
private Spine.Unity.SkeletonGraphic skeletonGraphic;
|
|
private Spine.AnimationState animationState;
|
|
|
|
void Awake()
|
|
{
|
|
skeletonGraphic = this.GetComponent<Spine.Unity.SkeletonGraphic>();
|
|
animationState = skeletonGraphic.AnimationState;
|
|
}
|
|
|
|
public void Reload()
|
|
{
|
|
animationState = skeletonGraphic.AnimationState;
|
|
}
|
|
|
|
public List<float> GetAnimationKeyFrameTime(string name)
|
|
{
|
|
List<float> times = new List<float>();
|
|
var animation = skeletonGraphic.skeletonDataAsset.GetAnimationStateData().SkeletonData.FindAnimation(name);
|
|
foreach (var timeline in animation.Timelines)
|
|
{
|
|
var eventTimeline = timeline as Spine.EventTimeline;
|
|
if (eventTimeline != null && eventTimeline.Events.Length > 0)
|
|
{
|
|
foreach (var eventInfo in eventTimeline.Events)
|
|
{
|
|
times.Add(eventInfo.Time);
|
|
}
|
|
}
|
|
}
|
|
return times;
|
|
}
|
|
}
|
|
}
|