(手册)Animation 之 使用Animation View

来源:互联网 发布:手机淘宝怎么找代理 编辑:程序博客网 时间:2024/06/07 05:31

观看游戏物体上的动画(Viewing Animations on a GameObject)

Animation View 是与 Hierarchy ViewScene ViewInspector紧密结合在一起的。Animation View会显示出当前选择的游戏物体的动画的时间轴和关键帧。你可以在Hierarchy View 或 Scene View 中选择一个游戏物体。(如果你在Project View中选择一个Prefab,你仍然可以查看它的动画时间轴,但是如果想要编辑动画,你必须将Prefab拖拽到Scene View)      


动画属性列表(The Animated Properties List)

The Animation View (left) shows the animation used by the currently selected Game Object, and its child objects if they are also controlled by this animation. The scene view and hierarchy view are shown on the right, demonstrating that the animation view shows the currently selected object.


Animation View 的左侧是一个动画属性列表。在一个新建的、还有任何动画记录的剪辑中,列表是空的。如果游戏物体包含着多个子对象,那么所有子对象的动画属性的层级关系也将包含在列表中。在上图中,Robot Arm层级的每个部分的动画都包含在一个动画剪辑中,并且每个动画都根据其游戏物体在层级关系中的位置而相应的显示。

每个属性都可以被折叠起来,或者展开来显示每个关键帧的精确的值。如果播放线(那条红线)在两个关键帧之间,则属性值显示为一个插值。属性值字段可以被直接修改。当播放线在一个关键帧上时,如果改变属性值字段的值,那么这个关键帧的值将被修改。如果改变发生在播放线在两个关键帧之间时(此时字段显示插值),一个新的关键帧将在这个位置被创建,其值是你输入的值。

An unfolded property in the Animation View, allowing the keyframe value to be typed in directly. In this image, an interpolated value is shown because the playback head (the red line) is between keyframes. Entering a new value at this point would create a new keyframe.


动画时间轴(The Animation Timeline)

Animation View 的右侧是当前剪辑的时间轴。每个属性的关键帧显示在这个时间轴里。时间轴视图有两种模式,"信息清单(Dope Sheet)"模式和"曲线(Curves)"模式。 你可以通过点击动画属性列表下边的区域的按钮,在两种模式中选择。

The Dope Sheet / Curves view buttons


信息清单时间轴模式(Dope Sheet Timeline Mode)

信息清单模式的视图更加简洁,在水平方向上,你可以看到属性的每个关键帧的队列。这可以使你对多个属性或对象的关键帧有一个简单的概述。

Here the Animation Window is in Dope Sheet mode, showing the keyframe positions all the animated properties within the Animation Clip


曲线时间轴模式(Curves Timeline Mode)

曲线模式可以让我们看到动画属性的值是如何随着时间变化的。所有选择的属性将显示在同一个图表中。这种模式下你可以看到在两个值之间是如何进行插值的。

Here the Animation Window is showing the curves for the rotation data of four selected GameObjects within this animation clip


当使用曲线模式来查看你的动画时,请注意有时看起来属性区间的变化非常大。例如,一个简单的动画剪辑,立方体的旋转和跳跃。其跳跃在Y轴上的变化也许是0到2之间,然而旋转的值可能是0到360。当同时查看这两个曲线的时候,曲线的位置差距非常大,因为视图被缩放到适应0到360的区间。

The position and rotation curves of a bouncing spinning cube are both selected, but because the view is zoomed out to fit the 0-360 range of the rotation curve, the bouncing Y position curve is not discernible


你可以点击个别的属性,曲线视图会自动的缩放来适应属性的区间,你也可以通过滑动条来手动的矫正曲线窗口。

Here the Animation Window is zoomed in to view the bouncing Y position animation. The start of the yellow rotation curve is still visible, but now extends way off the top of the view.


创建一个新的动画剪辑(Creating a New Animation Clip)

为了使游戏对象动起来,需要为游戏对象添加Animator组件。Animator组件必须引用一个Animator Controller, 而这个Animator Controller需要包含一个或多个动画剪辑。

当使用Animation View来为对象创建动画时,所需的项会被自动的创建、添加和设置。

要为游戏物体创建一个新的动画剪辑,点击Animation View左上角的选择框,并且旋转[Create New Clip]。你会被提示在你的资源文件夹里保持动画剪辑。如果游戏对象已经附加了Animator组件,并且分配了一个Animator Controller,那么新的剪辑将作为一个状态添加到已存在的Animator Controller里。

Create a new Animation Clip


如果游戏对象还没有Animator 组件,以下事件将自动完成:

  • 一个新的Animator Controller资源被创建。
  • 新创建的剪辑作为默认状态被添加到Animator Controller中。
  • 一个Animator组件被添加到游戏对象上。
  • 新创建的Animator Controller被分配给Animator组件。

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


下图中,你可以看到一个还没有添加动画的游戏对象。我们仅仅有一个简单的立方体,还没有添加Animator组件。Animation, Hierarchy, Project and Inspector窗口被边靠边的排在一起,这样看起来更直观。

Before: An un-animated gameobject (Cube) is selected. It does not yet have an Animator Component, and no Animator Controller exists.


通过点击Animation view(left)中的record button,或者在选择框中选择“[Create New Clip]”,可以创建一个新的动画剪辑。Unity会要求选择保存这个剪辑的名字和位置。Unity同时会创建一个新的Animator Controller资源,并且以选择的游戏对象的名字命名,并且为游戏对象添加一个Animator组件,并且将资源联系在一起。

After: After creating a new clip, you can see the new assets created in the 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 the Animator Window



给游戏物体添加动画(Animating a Game Object)

当你保存了新的动画剪辑资源后,你就可以为剪辑添加关键帧了。点击Record button来编辑选择的游戏对象的动画剪辑。

Record button


你可以在任何时刻点击Record button来停止Record模式。停止后,游戏对象的动画状态将回到最开始状态。

在红线所显示的当前关键帧的位置,你对游戏对象做的改变将被记录下来。

在Record模式下,你可以通过操作游戏对象来改变动画的任意属性。移动、旋转或缩放对象,都会改变相应的关键帧处的动画属性的值。在Record模式下,直接在inspector中改变对象的值也会改变相应的关键帧处的值。这适用于inspector中的任何属性,包括数值,复选框,颜色以及其他值。游戏对象的所有添加到动画的属性(animated properties)都显示在Animation窗口的左侧的属性列表中。没有被动画的属性(not animated)将不被显示。

Transform属性是指已经连接的 .x、.y和 .z属性,所以曲线被添加三次。

你也可以通过点击Add Curve按钮浏览所有可以被动画的属性。

Add curves


Animation 模式下,一条垂直的红线显示了动画剪辑中当前正在预览的帧。Inspector andScene View将显示当前帧下的游戏对象。动画属性在这一帧时的值将显示在其名字的右边。

Current frame


时间轴(Time Line)

你可以点击时间轴的任意一处来预览或修改剪辑的那一帧。时间轴的显示方式是秒和帧数,1:30表示1秒和30帧。

Time Line


动画模式(Animation Mode)

在动画模式下,你可以在Scene View中移动、旋转或缩放游戏对象。这也将为你自动创建位置、旋转和缩放属性的曲线,如果他们还不存在。


0 0
原创粉丝点击