找回密碼
 注冊帳號

掃一掃,訪問微社區

animation.crossfade 淡入淡出

2014-12-31 01:34| 發布者: 楊炎| 查看: 2768| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: animation.crossfade 淡入淡出functioncrossfade(animation: string,fadelength: float = 0.3f,mode:playmode=playmode.stopsamelayer) : voiddescription描述fades the animation with name animation in over a pe ...

animation.crossfade 淡入淡出

functioncrossfade(animation: string,fadelength: float = 0.3f,mode:playmode=playmode.stopsamelayer) : void

description描述

fades the animation with name animation in over a period of time seconds and fades other animations out.

在一定時間內淡入名稱為name的動畫并且淡出其他動畫。

if mode is playmode.stopsamelayer, animations in the same layer as animation will be faded out while animation is faded in. if mode is playmode.stopall, all animations will be faded out while animation is faded in.

如果模式是playmode.stopsamelayer,在同一層的動畫將在動畫淡入的時候淡出。如果模式是playmode.stopall,所有動畫將在淡入的時候淡出。

if the animation is not set to be looping it will be stopped and rewinded after playing.

如果動畫沒有被設置成循環,它將停止并且在播放完成之后倒帶至開始。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

public void awake() {

animation.crossfade("walk", 0.2f);

}

}

// 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);

另一個例子:

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void update() {

if (mathf.abs(input.getaxis("vertical")) > 0.1f)

animation.crossfade("run");

else

animation.crossfade("idle");

}

}

// 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");

}

相關閱讀

文章點評
相關文章
女校游泳队彩金