Creating Timeline Playable Asset from code

Hello.
First I’m sorry if this is in the wrong thread. I don’t know If I should put this to Editor Scripting or Timeline
I’m trying to automate a process for creating timeline with activation tracks. The idea is to have the designer to create a list of gameObject and the time to activate/deactivate each. From that information, I will create a timeline playable with activation tracks corresponding to the activate/deactivate time. So the overall flow is:

  • Designer creates a list of game objects with activation time.
  • From the list, create corresponding activation tracks for each gameObject in the list, with activation and deactivation time.

The step that I’m curious is that if I were to create the playable asset alone, I still need to load into a Director, then manually drag and drop gameObject into it. Is there a way to automate this too?

I don’t have a lot of experience with Editor Scripting. Can someone give a general idea?
Thank you very much.

You can use this property to set your PlayableAsset in the PlayableDirector.

Then for every track in your newly created TimelineAsset, you need to call PlayableDirector.SetGenericBinding(track, )

1 Like

Thank you very much.
Regarding actually creating the PlayableAsset, as I read on the documentation, there are also PlayableGraph and a few other things relating to creating a PlayableAsset from code. As I mentioned, I don’t have a lot of experience with Editor Scripting. Where in the documentation should I read to know how to actually create a PlayableAsset and save it in a specific folder (and also delete them if the designer wants)?

Assuming you are only assembling a Timeline, you shouldn’t have to worry too much about PlayableGraph.

But yes, you need to call AssetDatabase.CreateAsset in order to save your asset to disk.