public Animation anim;
//动画
public GameObject btn;
//按钮
private Vector3 sx = new Vector3(0.02f, 0.02f, 0.02f);
//缩小系数,缩小系数越小缩小用到的时间越慢
private bool suo = false;
private bool fang = false;
private void Update()
{
//缩小
if(suo==true)
{
anim.gameObject.transform.localScale = anim.gameObject.transform.localScale- sx;
if(anim.gameObject .transform .localScale.x <= 3.5f)
{
anim.gameObject.transform.localScale = new Vector3(3.5f, 3.5f, 3.5f);
suo = false;
}
}
//放大
if (fang == true)
{
anim.gameObject.transform.localScale = anim.gameObject.transform.localScale + sx;
if (anim.gameObject.transform.localScale.x >= 6f)
{
anim.gameObject.transform.localScale = new Vector3(6f, 6f, 6f);
fang = false;
}
}
}
public void OnClick1()
{
anim.Play(“baozha”);//爆炸播放
btn.SetActive(false);
//缩小
suo = true;
anim.gameObject.transform.localScale = new Vector3(6f, 6f, 6f);
}
public void OnClick2()
{
anim.Play(“huanyuan”);//还原播放
btn.SetActive(true);
fang = true;
anim.gameObject.transform.localScale = new Vector3(3.5f, 3.5f, 3.5f);
}