mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
39 lines
770 B
C#
39 lines
770 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(SkeletonRenderer))]
|
|
public class SpineGauge : MonoBehaviour{
|
|
|
|
[Range(0,1)]
|
|
public float fill = 0;
|
|
|
|
[SpineAnimation]
|
|
public string fillAnimationName;
|
|
Spine.Animation fillAnimation;
|
|
|
|
SkeletonRenderer skeletonRenderer;
|
|
|
|
void Start () {
|
|
skeletonRenderer = GetComponent<SkeletonRenderer>();
|
|
}
|
|
|
|
void Update () {
|
|
|
|
var skeleton = skeletonRenderer.skeleton;
|
|
|
|
if (skeleton == null)
|
|
return;
|
|
|
|
if (fillAnimation == null) {
|
|
fillAnimation = skeleton.Data.FindAnimation(fillAnimationName);
|
|
if (fillAnimation == null)
|
|
return;
|
|
}
|
|
|
|
fillAnimation.Apply(skeleton, 0, fill, false, null);
|
|
skeleton.Update(Time.deltaTime);
|
|
skeleton.UpdateWorldTransform();
|
|
}
|
|
}
|