Unity 2017.1功能聚焦:可播放的API

It’s time. It’s been a long run, but here we are: in Unity 2017.1 the Playable API is out of experimental.

是时候了。 这已经很长一段时间了,但是我们要做的是:在Unity 2017.1中,Playable API处于试验阶段。

The graph-like Playable API allows you to have precise programmatic control over animation and audio – we are also working on using the same API for video control. Our brand new Timeline tool in 2017.1 uses the Playable API.

类似于图形的Playable API使您可以对动画和音频进行精确的编程控制-我们也在努力使用相同的API进行视频控制。 我们2017.1中全新的时间轴工具使用了Playable API。

For animation, this provides a level of control that was not possible before with the Animator:

对于动画,这提供了Animator之前无法实现的控制级别:

  • Play an AnimationClip on an Animator without an AnimatorController

    在没有AnimatorController的情况下在Animator上播放AnimationClip

  • Direct control of the timing and the weight of each individual AnimationClip being played

    直接控制正在播放的每个AnimationClip的时间和权重

  • Dynamically add AnimationClips to the graph at runtime

    在运行时动态地将AnimationClips添加到图形

  • Mix AnimatorController with AnimationClips, other AnimatorControllers, or even with Timeline!

    将AnimatorController与AnimationClips,其他AnimatorController甚至与时间轴混合!

I wrote a blog post sometime ago regarding this, which you can read here.

不久前,我写了一篇关于此的博客文章,您可以 在此处 阅读 。

In order to make it easier for users to create and debug, we created a PlayableGraph Visualizer tool. The tool can be used to display any PlayableGraph in both Play and Edit mode and will always reflect the current state of the graph. Playables in the graph are represented by colored nodes, varying according to their type. Wire color intensity indicates the local weight of the blending. You can get the visualizer tool on our github.

为了使用户更容易创建和调试,我们创建了PlayableGraph Visualizer工具。 该工具可用于在“播放”和“编辑”模式下显示任何PlayableGraph,并将始终反映图形的当前状态。 图中的可玩游戏由有色节点表示,根据其类型而变化。 电线颜色强度指示混合的局部重量。 您可以 在我们的github上 获得可视化工具

Note that the API has changed a bit from 5.6 to 2017.1. We’ve just finished writing a manual so you can see what it’s all about.

请注意,API从5.6更改为2017.1。 我们刚刚完成了手册的编写,因此您可以了解手册的全部内容。

Something that is really interesting about this API is that for all “native” playables that Unity provides, we use C# structs instead of C++ objects to hold the objects. Using structs has the advantage of not allocating GC memory. It can be a bit more tricky to use, but since we are building a lot of our future technologies with this API this was important for us.

关于此API的真正有趣之处在于,对于Unity提供的所有“本机”可玩游戏,我们使用C#结构而不是C ++对象来保存对象。 使用结构的优点是不分配GC内存。 使用起来可能会有些棘手,但是由于我们正在使用此API构建很多未来的技术,因此这对我们很重要。

It’s now possible for our users to implement and tailor their own systems and API that rely on Playables. For instance, for those who are still fond of the Legacy Animation system, we are currently implementing – using Playable API – a frontend API that mimics the behavior of the Legacy system but using Mecanim. This will soon be available via our GitHub. For now, let’s just see a small example:

现在,我们的用户可以实现和定制依赖于Playables的自己的系统和API。 例如,对于仍然喜欢旧版动画系统的用户,我们目前正在使用Playable API来实现一个模仿旧版系统行为但使用Mecanim的前端API。 这将很快通过我们的GitHub提供。 现在,让我们看一个小例子:

演示地址

With this, you get the benefits of our multithreaded and retargetable animation engine but with a Legacy-like level of control.

这样,您就可以享受我们的多线程和可重定目标的动画引擎的好处,但具有类似Legacy的控制级别。

可玩行为 (PlayableBehaviour)

When the Playables API was still in the experimental phase we had something called ScriptPlayable. It was both the container (the playable node) and the content (your custom code). We’ve since split this concept in two: the ScriptPlayable is now just the container and the PlayableBehaviour is the content.

当Playables API仍处于实验阶段时,我们有了一个叫做ScriptPlayable的东西。 它既是容器(可播放的节点),也是内容(您的自定义代码)。 此后,我们将此概念分为两​​部分:ScriptPlayable现在只是容器,而PlayableBehaviour是内容。

From the manual we have :

从手册中我们可以得到:

The Playables API allows you to create custom playables derived from PlayableBehaviour. By overriding the ‘PrepareFrame’ method, nodes can be handled as desired. Custom Playables can also override any of the other virtual methods of PlayableBehaviour, based on the event that they need to handle.

Playables API允许您创建派生自PlayableBehaviour的自定义可玩游戏。 通过覆盖“ PrepareFrame”方法,可以根据需要处理节点。 自定义可玩对象还可以根据需要处理的事件来覆盖PlayableBehaviour的其他任何虚拟方法。

For instance, a basic Playable would look like this:

例如,基本的Playable如下所示:

1

2
3
4
5
6
7
public class MyNicePlayableBehaviour : PlayableBehaviour
{
    override public void PrepareFrame(Playable owner, FrameData info)
    {
    }
}

1

2
3
4
5
6
7
public class MyNicePlayableBehaviour : PlayableBehaviour
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值