using UnityEngine;
using System.Collections.Generic;
public class UIAnimatedButton : MonoBehaviour
{
public UIAtlas normalSprite;
public UIAtlas hoverSprite;
public UIAtlas pressedSprite;
private UISprite buttonObject;
private UISpriteAnimation anime;
public void Awake()
{
buttonObject = gameObject.GetComponent<UISprite>();
anime = gameObject.GetComponent<UISpriteAnimation>();
}
public void OnMouseEnter()
{
Destroy(anime);
buttonObject.atlas = hoverSprite;
gameObject.AddComponent<UISpriteAnimation>();
}
public void OnMouseExit()
{
Destroy(anime);
buttonObject.atlas = normalSprite;
gameObject.AddComponent<UISpriteAnimation>();
}
public void OnMouseDown()
{
Destroy(anime);
buttonObject.atlas = pressedSprite;
gameObject.AddComponent<UISpriteAnimation>();
}
}