Animation.AddClip 添加剪辑


function AddClip (clip : AnimationClip, newName : string) : void

Description描述

Adds a clip to the animation with name newName.

给动画添加一个名称为newName的动画剪辑。

  • C#

  • JavaScript

using UnityEngine;using System.Collections;public class example : MonoBehaviour {public AnimationClip walkClip;public void Awake() {animation.AddClip(walkClip, "walk");}}
var walkClip : AnimationClip;animation.AddClip(walkClip, "walk");

• function AddClip (clip : AnimationClip, newName : string, firstFrame : int, lastFrame : int, addLoopFrame : bool = false) : void

Description描述

Adds clip to the only play between firstFrame and lastFrame. The new clip will also be added to the animation with name newName.

 在播放的firstFrame和lastFrame之间添加动画剪辑。新的动画剪辑也会被添加到名称为newName的动画中。

addLoopFrame: Should an extra frame be inserted at the end that matches the first frame? Turn this on if you are making a looping animation. If a clip with that name already exists it will be replaced with the new clip.

 addLoopFrame: 是否在第一帧之后添加一个额外的帧?如果你在制作一个循环的动画,那么可以打开这个选项。如果那么名称的动画剪辑已经存在,那么会被新的动画剪辑覆盖。

  • C#

  • JavaScript

using UnityEngine;using System.Collections;public class example : MonoBehaviour {public void Awake() {animation.AddClip(animation.clip, "shoot", 0, 10);animation.AddClip(animation.clip, "walk", 11, 20, true);animation.AddClip(animation.clip, "idle", 21, 30, true);}}
// Split the default clip into a shoot, walk and idle animation// 把默认的动画剪辑拆分成一个shoot,walk和idle的动画。animation.AddClip(animation.clip, "shoot", 0, 10);// walk and idle will add an extra looping frame at the end// walk和idle动画剪辑会在结尾被添加一个额外的循环帧。animation.AddClip(animation.clip, "walk", 11, 20, true);animation.AddClip(animation.clip, "idle", 21, 30, true);


,