zoukankan      html  css  js  c++  java
  • (手冊)Animation 之 使用Animation View

    观看游戏物体上的动画(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)"模式。 你能够通过点击动画属性列表下边的区域的button。在两种模式中选择。

    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 Curvebutton浏览全部能够被动画的属性。

    Add curves


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

    Current frame


    时间轴(Time Line)

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

    Time Line


    动画模式(Animation Mode)

    在动画模式下。你能够在Scene View中移动、旋转或缩放游戏对象。

    这也将为你自己主动创建位置、旋转和缩放属性的曲线,假设他们还不存在。


  • 相关阅读:
    异或和之和
    Wannafly挑战赛19C:多彩的树
    HDU 6035 树形dp
    利用C++套接字发送邮件
    洛谷P3368树状模板(区间更新+单点查询+差分)
    CCF 201903-1 小中大
    关于树状数组
    CODEVS 4189 (前缀是否出现)
    关于字典树
    hdu 1022 Train Problem
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7221970.html
Copyright © 2011-2022 走看看