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
{
}
'''

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;
}
}
}
'''

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,392评论 5 470
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,258评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,417评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,992评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,930评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,199评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,652评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,327评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,463评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,382评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,432评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,118评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,704评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,787评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,999评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,476评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,057评论 2 341