Search Unity

Question Creating Timeline Playable Asset from code

Discussion in 'Timeline' started by NDSno1, Jan 13, 2021.

  1. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    223
    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.
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    NDSno1 likes this.
  3. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    223
    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)?
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    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.