Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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.