if (Input.GetMouseButtonDown(0))
{if (isKai == false)
{
//切换动画状态
kai.speed = 1;
kai.CrossFade("kai", 0.1f);
isKai = true;
}
else
{
kai.CrossFade("guan", 0.1f);
isKai = false;
}
}
//判断动画是否播放完成
AnimatorStateInfo stateinfo = kai.GetCurrentAnimatorStateInfo(0);
//如果正在播放walk动画.
if (stateinfo.IsName("kai"))
{
if (stateinfo.normalizedTime >= 1.0f)
{
print("开关已经开了!");
}
}
if (stateinfo.IsName("guan"))
{
if (stateinfo.normalizedTime >= 1.0f)
{
print("开关已经关闭!");
}
}