- 最后登录
- 2017-5-15
- 注册时间
- 2012-3-1
- 阅读权限
- 90
- 积分
- 32973
![Rank: 7](static/image/common//star_level3.gif) ![Rank: 7](static/image/common//star_level2.gif) ![Rank: 7](static/image/common//star_level1.gif)
- 纳金币
- 32806
- 精华
- 12
|
Animation.Play播放
function Play (mode : PlayMode = PlayMode.StopsameLayer) : bool
function Play (animation : string, mode : PlayMode = PlayMode.StopSameLayer) : bool
复制代码
Play()将开始播放名称为animation的动画,或者播放默认动画。动画会突然开始播放而没有任何混合。
如果模式是PlayMode.StopSameLayer,那么所有在同一个层的动画将停止播放。如果模式是PlayMode.StopAll,那么所有当前在播放的动画将停止播放。
如果动画已经在播放过程中,别的动画将停止但是动画不会回退到开始位置。
如果动画没有被设置成循环模式,它将停止并且回退到开始位置。
如果动画不能被播放(没有动画剪辑或者没有默认动画),Play()将返回false。
// 播放默认动画。
animation.Play();
// Plays the walk animation - stops all other animations in the same layer
// 播放walk动画 - 停止同一层的其他动画。
animation.Play("walk");
// Plays the walk animation - stops all other animations
// 播放walk动画 - 停止其他动画。
animation.Play("walk", PlayMode.StopAll);
复制代码
Animation.CrossFade淡入淡出
function CrossFade (animation : string, fadeLength : float = 0.3F, mode : PlayMode = PlayMode.StopSameLayer) : void
复制代码
在一定时间内淡入名称为name的动画并且淡出其他动画。
如果模式是PlayMode.StopSameLayer,在同一层的动画将在动画淡入的时候淡出。如果模式是PlayMode.StopAll,所有动画将在淡入的时候淡出。
如果动画没有被设置成循环,它将停止并且在播放完成之后倒带至开始。
// Fade the walk cycle in and fade all other animations in the same layer out.
// 淡入walk循环并且淡出同一层的所有其他动画。
// Complete the fade within 0.2 seconds.
// 在0.2秒之内完成淡入淡出。
animation.CrossFade("Walk", 0.2);
复制代码
// Makes a character contains a Run and Idle animation
// fade between them when the player wants to move
// 让一个角色包含Run和Idle动画,并且在玩家想移动的时候在他们之间淡入淡出。
function Update () {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("Run");
else
animation.CrossFade("Idle");
}
复制代码
Animation.Sample采样
function Sample () : void
在当前状态对动画进行采样。
当你明确想设置一些动画状态并且对它取样一次的时候有用。
// Set up some state;
// 设置一些状态;
animation["MyClip"].time = 2.0;
animation["MyClip"].enabled = ***e;
// Sample animations now.
// 取样动画。
animation.Sample();
animation["MyClip"].enabled = false;
复制代码
Animation.Stop 停止
function Stop () : void
复制代码
// Stop all animations
//停止所有动画。
animation.Stop();
复制代码
Animation.this[string name]操作名字
var this[name : string] : AnimationState
复制代码
// Get the walk animation state and set its speed
// 取得walk动画状态并设置其速度。
animation["walk"].speed = 2.0;
// Get the***n animation state and set its weight
// 取***n动画状态并设置其重量。
animation["***n"].weight = 0.5;
复制代码
Animation.wrapMode循环模式
动画剪辑播放完成之后,应该如何操作?
WrapMode.Default:从动画剪辑中读取循环模式(默认是Once)。
WrapMode.Once:当时间播放到末尾的时候停止动画的播放。
WrapMode.Loop:当时间播放到末尾的时候重新播放从开始播放。
WrapMode.ClampForever:播放动画。当播放到结尾的时候,动画总是处于最后一帧的采样状态。
//Make the animation loop
//使用动画循环模式。
animation.wrapMode = WrapMode.Loop;
如果要查看其他属性及方法,请登录http://3d.ceeger.com/Script/Animation/Animation.wrapMode.html
|
|