animeditor-Creating a New Animation Clip

来源:互联网 发布:js显示隐藏div切换 编辑:程序博客网 时间:2024/06/01 09:20

Creating a New Animation Clip

To animate Game Objects in Unity, theobject or objects need an AnimatorComponent attached. This Animator Component must reference an Animator Controller, which in turncontains references to one or more Animation Clips.

When using the Animation View to beginanimating a GameObject in Unity, all these items will be automatically created,attached and set-up for you.

To create a new Animation Clip for the selected GameObject, and makesure the AnimationWindow is visible.

If the GameObject does not yet have anyAnimation Clips assigned, you will see the “Create” button in the centre of theAnimation Window timeline area. Click the Create button. You will then beprompted to save your new empty Animation Clip somewhere in your Assets folder.

为了使游戏对象在Unity中运动,对象需要附加一个动画器组件。这个动画器组件必须引用一个动画器控制器,而这个控制器又包含对一个或多个动画剪辑的引用。

当使用动画视图开始在Unity中制作一个游戏对象动画时,所有这些项目将会为您自动创建,附加并设置。

要为所选的游戏对象创建一个新的动画剪辑,确保动画窗口是可见的。

如果游戏对象没有指定任何动画剪辑,您将在动画窗口时间轴区域的中心看到“Create”按钮。点击“Create”按钮。然后,您将被提示在您的Assets 文件夹中保存新的空动画剪辑。

 

Create a new Animation Clip

 

Once you have saved this new emptyAnimation Clip, a number of things happen automatically:

.   A new Animator Controller asset will be will be created

·  The new clip being created will be added into theAnimator Controller as the default state

·  An Animator Component will be added to the GameObjectbeing animated

·  The Animator Component will have the new AnimatorController assigned to it

The result of this automatic sequence isthat all the required elements of the animation system are set up for you, andyou can now begin animating the objects.

一旦你保存了这个新的空动画剪辑,会自动发生如下很多事情:

·        将创建一个新的动画器控制器资产

·        创建的新剪辑将作为默认状态添加到动画器控制器中

·        一个动画器组件将被添加到正在被制作动画的游戏对象中

·        动画器组件将会有分配给它的新的动画器控制器

这个自动续发事件的结果是为您设置了动画系统所需的所有元素,现在您可以开始对对象进行动画了


Adding another Animation Clip

If the Game Object already has one ormore Animation Clips assigned, the “Create” button will not be visible.Instead, one of the clips will be visible in the animation window. You canswitch between which Animation Clip is visible in the window by using the menuin the top-left of the Animation window, just under the playback controls.

If you want to create a new AnimationClip on an object that already has animations, you must select  “Create New Clip” from this menu. Again, you will be prompted to save yournew empty Animation Clip before being able to work with it.

添加另一个动画剪辑

如果游戏对象已经有一个或多个动画剪辑,那么“Create”按钮将不可见。相反,其中一个剪辑将在动画窗口中可见。你可以通过使用动画窗口左上角的菜单来切换在窗口中可见的动画剪辑,就在播放控件下面。

如果你想在已经有动画的对象上创建一个新的动画剪辑,您必须从这个菜单中选择“Create New Clip同样,在能够使用它之前,您将被提示保存您的新的空动画剪辑。


Adding an additional new Animation Clip to an objectwhich already has some clips assigned


 

How it fits together

While the above steps automatically setup the relevant components and references, it can useful to understand whichpieces must be connected together.

·        A GameObject must have an Animator component

·        The Animator component must have an Animator Controller asset assigned

·        The Animator Controller asset must have one or moreAnimation Clips assigned

The diagram below shows how these piecesare assigned, starting from the new animation clip created in the AnimationWindow:

动画剪辑怎么组合在一起

虽然上面的步骤会自动设置相关的组件和引用,但是理解哪些部分必须连接在一起是很有用的。

·        一个游戏对象(GameObject必须有一个动画器组件(Animator component

·        动画器组件(Animator component必须有一个指定的动画器控制器Animator Controller)资产

·        动画器控制器AnimatorController)资产必须有一个或多个指定的动画剪辑(Animation Clips

下图展示了如何分配这些片段,从动画窗口中创建的新动画片段开始:


A new clip is created, and saved as an asset. The clip is automaticallyadded as the default state to a new Animator Controller which is also saved asan asset. The Animator Controller is assigned to an Animator Component which isadded to the GameObject.


 In the image below, you can see a GameObject selected(“Cube”) that is not yet animated. We have just a simple cube, with no Animatorcomponent. The Animation, Hierarchy, Project and Inspector windows are arranged side-by-side for clarity.

在下面的图像中,您可以看到一个尚未被动画的游戏对象 (“立方体”)。我们只有一个简单的立方体,没有动画器组件。AnimationHierarchyProjectInspector窗口都是清晰的而并排排列的。


Before: An un-animated gameobject (“Cube”) isselected. It does not yet have an Animator Component, and no AnimatorController exists.

 

By pressing the create button in the Animation view, anew animation clip is created. Unity will ask to pick the name & locationto save this new Animation Clip. Unity also creates an Animator Controller asset with the same name as the selected GameObject, adds an Animator componentto the GameObject, and connects the assets up appropriately.

通过在动画视图中按下create按钮,将创建一个新的动画片段。Unity会要求选择名称和位置来保存这个新的动画剪辑。Unity还创建了一个与选择的游戏对象同名的Animator Controller资产,将一个动画器组件添加到GameObject中,并适当地将这些资产连接起来。


After: After creating a new clip, you can see the new assets created inthe project window, and the Animator Component assigned in the Inspector window(far right). You can also see the new clip assigned as the default state in theAnimator Window


 In the new view above, you can see:

·        The Animation Window (top left) now shows a timeline witha red playback head line, ready to record new keyframes. The clip’s name isvisible in the clip menu, just below the playback controls.

·        The Inspector (center) shows that the Cube GameObject nowhas an Animator Component added, and the “Controller” field of thecomponent shows that an Animator Controller asset called “Cube” is assigned

·        The Project Window (bottom right) shows that two newassets have been created - An Animator Controller asset called “Cube” and anAnimation Clip asset called “Cube Animation Clip”

·        The Animator Window (bottom left) shows the contents ofthe Animator Controller - you can see that the Cube Animation Clip has beenadded to the controller, and that it is the “default state” as indicated by theorange color. Subsequent clips added to the controller would have a grey color,indicating they are not the default state.

在上面的新视图中,您可以看到:

·        动画窗口(左上角)现在显示一个带有红色播放头线的时间线,准备记录新的关键帧。这个剪辑的名字在剪辑菜单中是可见的,就在播放控件下面。

·        检查器(center)显示现在立方体游戏对象添加了一个Animator组件,并且组件的控制器字段显示了一个名为“Cube”的动画器控制器资产

·        项目窗口(右下角)显示已经创建了两个新资产 —-- 一个名为Cube的动画控制器资产和一个名为Cube Animation Clip的动画剪辑资产。

·        动画器窗口(底部左边)显示了动画器控制器的内容 —— 您可以看到,Cube动画剪辑被添加到控制器中,并且它是橙色表示的默认状态。添加到控制器的后续剪辑将有灰色的颜色,表示它们不是默认状态。