Animation.SyncLayer 同步层
function SyncLayer (layer : int) : void
Description描述
Synchronizes playback speed of all animations in the layer.
同步某层的动画的播放速度。
When blending between two looping animations they often have different lengths. For example a walk cycle often takes longer than a run cycle. When blending between them you need to make sure that the foot placement of the walk and run cycle happens at the same time. In other word playback speed of the animations must be adjusted so that the animations are synchronized. SyncLayer will calculate the average normalized playback speed of all animations in the layer based on their blend weight. Then it will apply that playback speed to all animations in the layer.
在混合两个循环动画的时候,他们通常有不同的长度。比如一个走路的动画通常比一个跑步的动画要长。当混合他们的时候,你需要确定走路和跑步动画发生的时候脚的位置要在同一时间走动。换句话说,这两个动画播放速度要被调整一致,以便动画的同步。SyncLayer函数将根据动画的混合权重来计算同一层中动画的平均正常播放速度。然后它会给同一层的所有动画应用这个播放速度。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public void Awake() {
animation["walk"].layer = 1;
animation["run"].layer = 1;
animation.SyncLayer(1);
}
}
// Puts the walk and run animation in the same
// layer and synchronizes their speed
// 把walk和run动画放到同一层,然后同步他们的速度。
animation["walk"].layer = 1;
animation["run"].layer = 1;
animation.SyncLayer(1);