Unity中Animation动画的相关播放(顺播倒播等)
2016-06-07 17:09
525 查看
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("不存在该动画");
}
}
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("不存在该动画");
}
}
相关文章推荐
- unity如何使用ios模拟器运行(需要xcode)
- [置顶] unity中关于异步loading场景的加载
- [置顶] Unity 中关于获取到物体的方式
- Unity 5 事件/消息机制之UnityEvent类型
- 【Unity】C#特性Attribute与自动化
- Unity APP接入百度移动广告
- Unity中网格合并示例研究。针对合并子网格列表后再合并网格
- Unity查找Editor下Project视图中特定的资源
- unity3d泰斗破坏神2----课程列表
- Unity学习日常问题记录七--尝试编写部分自己简单的碰撞规则一
- 如何在 Unity 2D 和 3D 中放大或缩小以及点击屏幕
- Unity Sprite Packer 问题集合
- [Unity3D]脚本中Start()和Awake()的区别
- 【我的书】《Unity Shader入门精要》出版上市
- Unity Shader简单Shader一
- unity5.4 UGUI 手机屏幕自适应分辨率
- 【Unity】修复因GameObject层级变化而导致的animationclip内容丢失
- Unity 像子弹一样的方块+计数功能
- UnityShader快速上手指南(四)
- UnityShader快速上手指南(四)