脚本:
public class SkillButtonAnim : MonoBehaviour {
/*
* 播放序列帧
*
*/
public UIAtlas atlas;
public bool PlayAnim = false;
[Range(0,0.1f)]
public float fireRate = 0.1f;
int i = 0;
float nextFire;
string[] ActivatorTexture ;
void Awake()
{
}
// Use this for initialization
void Start()
{
ActivatorTexture = atlas.GetListOfSprites().ToArray();
GetComponent<UISprite>().atlas = atlas;
this.GetComponent<UISprite>().spriteName = ActivatorTexture[0] ;
}
// Update is called once per frame
void Update()
{
if (PlayAnim)
{
if (i < ActivatorTexture.Length)
{
if (Time.time > nextFire)
{
nextFire = Time.time + fireRate;
this.GetComponent<UISprite>().spriteName = ActivatorTexture[i];
i++;
}
if (i==ActivatorTexture.Length-1)
{
PlayAnim = false;
}
}
else
{
i = 0;
}
}
else
{
if(!this.GetComponent<UISprite>().spriteName.Equals(ActivatorTexture[0]))
this.GetComponent<UISprite>().spriteName = ActivatorTexture[0];
}
}
}