Unity|Unity Timeline翻译

原文
Unity launched Timeline along with Unity 2017.1 and since then, we have received a lot of feedback about it.
Unity的Timeline功能是随着 Unity 2017.1 一起发布的, 并且直到现在,我们收到大量关于它的反馈。
After talking with many developers and responding to users on the forums,
在论坛上与很多开发者进行交流后,
we realized how many of you want to use Timeline for more than as a simple sequencing tool.
我们认识到你们想使用Timeline完成比简单的序列化工具 更多的功能
I have already delivered a couple of talks about this (for instance, at [Unite Austin 2017]>(https://www.youtube.com/watch?v=nn3SnfNNEmk)) and wrote a blog post on how to use Timeline for non-conventional uses.
我已经递上几个关于讲这方面的话题(例如,在 Unite Austin 2017)与写的一篇博客上面讲了 关于Timeline 的非传统使用方式
Read this blog post to find out about how Timeline can drive dialogues, support branching, or even connect with the AI systems of your game.
阅读这篇博客去找出如何使用Timeline驱动对话框, 支持分支, 甚至在你的游戏里关联AI系统.
Timeline was designed with extensibility as a main goal from the beginning;
一开始Tlimeline就是把可拓展性作为一个主要的目标。
the team which designed the feature always had in mind that users would want to create their own clips and tracks in addition to the built-in ones.
设计这个功能的团队一直会记在心上的事就是 用户会想创建它们自己的clips与tracks 整合到内置的功能这些功能中去。
As such, there are a lot of questions about scripting with Timeline. The system on which Timeline is built upon is powerful, but it can be difficult to work with for the non-initiated.
同样的,还有很多与Timeline相关的脚本问题。这是一个强大的系统,但是开始会比较难。
But first, what’s Timeline? It is a linear editing tool to sequence different elements: animation clips, music,
首先, 什么是Timeline? 它是一个线性编辑工具能编辑顺序排列的不用元素:动画片段, 音乐,
sound effects, camera shots, particle effects, and even other Timelines. In essence, it is very similar to tools
音效, 摄像机, 特效, 甚至其他Timeline. 本质上, 它非常像一些工具
such as Premiere?, After Effects?, or Final Cut?, with the difference that it is engineered for real-time
playback.
比如: Premiere?After Effects?, or Final Cut?(译者注:视频编辑工具) 区别在于这是为实时回放设计的.
For a more in-depth look at the basics of Timeline, I advise you to visit the Timeline documentation section of the Unity Manual, since I will make extensive use of those concepts.
要Timeline更细节的内容. 我建议你访问Unity手册中的Timeline文档, 因为我将会更广泛的使用这些概念。
The Playable API Timeline is implemented on top of the Playables API.
Timeline 的实现是基于Playables API
It is a set of powerful APIs that allows you to read and mix multiple data sources (animation, audio and more) and play them through an output.
这是一套强大的APIs, 允许你读取并混合多个数据源(动画, 声音更多) 并通过一个输出播放他们。
This system offers precise programmatic control, it has a low overhead and is tuned for performance.
Incidentally, it’s the same framework behind the state machine that drives the Animator Component, and if you have programmed for the Animator you will probably see some familiar concepts.
这套系统提供精确的可编程控制, 它拥有低开销并且是在性能上经过优化的。
顺带一提, 它是与state machine背后驱动Animator组件的框架用的是同一套, 如果你已经为Animator编写过程序你
或许会看到相似的概念。
Basically, when a Timeline begins playing, a graph is built composed of nodes called Playables. They are organised in a tree-like structure called the PlayableGraph.
基本上, 当一个Timeline开始播放, 一个由节点组成的图称为Playables. 它们组织成的一个树状结构叫 PlayableGraph.
Note: If you want to visualise the tree of any PlayableGraph in the scene (Animators, Timelines, etc.) you can download a tool called PlayableGraph Visualizer. This post uses it to visualize the graphs for the different custom clips. To know more about the Playable API and the graph (in relationship to the Animator), you can check Pierre-Paul’s blog post.
注意: 如果你想在场景中显示任何PlayableGraph的树状图(Animators, Timelines, etc.)你可以下载一个工具叫 PlayableGraph Visualizer.
这篇文章就是使用它去显示不同的自定义clips的图表. 要知道更多关于Playable API 和 这图表, 你可以访问
Pierre-Paul’s blog post.
I will now go through three simple examples that will show you how to extend Timeline.
我现在将通过3个范例给你展示如何拓展Timeline.
In order to lay the groundwork, I will begin with the easiest way to add a script in Timeline. Then, more concepts will be added gradually to make use of most of the functionalities.
为了先打下一个基础, 我将会从最简单的方式在Timeline中添加一个脚本. 然后, 更多的概念将会逐步的添加进来 最终产生一个大多数情况都能使用的版本.
Assets I have packaged a small demo project with all of the examples used in this post.
我有个包 a small demo project 包含了这篇博客上所有的例子。
Feel free to download it to follow along. Otherwise, you can enjoy the post on its own.
免费下载这个例子感受一下。或者,你可以自己愉快的阅读这篇博客。
Note: For the assets, I have used prefixes to differentiate the classes in each example (“Simple_”, “Track_”, “Mixer_”, etc.). In the code below, these prefixes are omitted for the sake of readability.
注意:对于assets, 我使用了一些前缀去区分每个例子的类名(“Simple_”, “Track_”, “Mixer_”, 等.).
在下面的代码里, 为了可读性这些前缀被已经被省略了.
Example 1 – Custom clips
范例 1 自定义clips
This first example is very simple: the goal is to change the color and intensity of a Light component with a custom clip. To create a custom clip, you need two scripts:
这第一个范例是非常简单的: 目标是用一个自定义的clip改变Light组件的颜色与强度.
要创建一个自定义clip, 你需要两个脚本:
One for the data: inheriting from PlayableAsset
一个用于数据:继承自PlayableAsset
One for the logic: inheriting from PlayableBehaviour
一个用于逻辑:继承自PlayableBehaviour
A core tenet of the Playable API is the separation of logic and data. This is why you will need to first create a PlayableBehaviour, in which you will write what you want to do, like so:
1个核心的原则是Playable API逻辑与数据是分离的. 这就是为什么当你想做任何事情之前, 你将需要先创建一个PlayableBehaviour,比如这样:
'''
public class LightControlBehaviour : PlayableBehaviour
{
}
'''
【Unity|Unity Timeline翻译】public class LightControlBehaviour : PlayableBehaviour
{
public Light light = null;
public Color color = Color.white;
public float intensity = 1f;
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
{
if (light != null)
{
light.color = color;
light.intensity = intensity;
}
}
}
'''

    推荐阅读