这篇文章将介绍如果实现一个自定义Timeline轨道。
![07640eb4263530ba957120143edda997.png](https://img-blog.csdnimg.cn/img_convert/07640eb4263530ba957120143edda997.png)
如上图所示,如果我们要实现自定义的Timeline轨道至少要创建4个脚本——CutomTrack,CustomClip,CustomMixer和CustomPlayableBehaviour。
(Custom代表你们想实现的Timeline的名字,比如要控制灯光,可以叫LightControllerTrack等等)接下来,我会分别介绍简单的代码和文字来介绍这四个脚本的作用。
1.CustomTrack(继承自TrackAsset)
[Serializable]//保证序列化
[TrackClipType(typeof(CustomClip))]//表示Track添加哪种Clip
[TrackBindingType(typeof(GameObject))]//表示Track绑定哪种类型的对象(GameObject或者任何Component等等)
[TrackColor(0.53f,0.0f,0.08f)]//表示在编辑器中,Track轨道前端的标识颜色(不重要啦)
public class CustomTrack : TrackAsset
{
//重写这个工厂方法,播放轨道的时候就会创建Mixer。
public override Playable CreateMixer(PlayableGraph graph,GameObject go,int inpu