public static void PlayerAnimationPlay(GameObject player,string Name){
if (player.transform.GetComponent<Animation> () != null) {
player.transform.GetComponent<Animation> ().Play(Name);
} else {
Debug.Log("不存在该动画");
}
}
public static void AnimationPlay(GameObject player,string Name){
if (player.transform.GetComponent<Animation> () != null) {
Animation curAnimation = player.transform.GetComponent<Animation>();
player.transform.GetComponent<Animation> ().wrapMode= WrapMode.Once;
curAnimation[Name].time =curAnimation[Name].clip.length - curAnimation[Name].clip.length;
curAnimation[Name].speed = 1;
curAnimation.Play(Name);
} else {
Debug.Log("不存在该动画");
}
}
public static void AnimationBackPlay(GameObject player,string Name){
if (player.transform.GetComponent<Animation> () != null) {
Animation curAnimation = player.transform.GetComponent<Animation>();
player.transform.GetComponent<Animation> ().wrapMode= WrapMode.Once;
curAnimation[Name].time =curAnimation[Name].clip.length;
curAnimation[Name].speed = -1;
curAnimation.Play(Name);
} else {
Debug.Log("不存在该动画");
}
}
public static void PlayerAnimationPlayAndSetState(GameObject player,string Name,bool loop){
if (player.transform.GetComponent<Animation> () != null) {
player.transform.GetComponent<Animation> ().Play(Name);
if(loop){
player.transform.GetComponent<Animation> ().wrapMode= WrapMode.Loop;
}else{
player.transform.GetComponent<Animation> ().wrapMode= WrapMode.Once;
}
} else {
Debug.Log("不存在该动画");
}
}