public enum PlayerState//枚举
{
Idle,
Walk,
Run,
Shoot
}
public class Player : MonoBehaviour
{
PlayerState p = PlayerState.Idle;//默认状态
void GetState(PlayerState p)
{
switch (p)
{
case PlayerState.Idle:
an.Play("Idle");
break;
case PlayerState.Walk:
an.Play("Walk");
break;
case PlayerState.Run:
an.Play("Run");
break;
case PlayerState.Shoot:
an.Play("Shoot");
break;
default:
break;
}
}