Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Generated timelines lose tracks when starting editor

Discussion in 'Timeline' started by oscar-schuurman, May 29, 2018.

  1. oscar-schuurman

    oscar-schuurman

    Joined:
    Aug 4, 2017
    Posts:
    2
    Hello,

    For a project that contains hundreds of timelines, I have to write an editor script that creates all these timelines. They are not very complex and consist of an audiotrack and an animation track. Both with a single clip. What the script does is:

    - Create a timelineasset
    - Create audio track
    - Set clip
    - Set bindings
    - Create animation track
    - Set clip
    - Set bindings
    - Set some values in the track (ease in, etc)
    - AssetDatabase.CreateAsset(timeline, path)

    This seems to work fine except for one major problem: when I close the editor and open it up again later, all the timelines are empty. I get the following warning twice for every timelineasset (there are two tracks in every asset, so that makes sense, I suppose):

    Empty track found while loading timeline. It will be removed.
    UnityEngine.Timeline.TimelineAsset:__internalAwake()

    When I create a timeline manually and take seemingly the same steps as my code, this problem does not occur. So I'm probably missing something in my script. Anybody know what it could be?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,049
    Move the AssetDatabase::CreateAsset to immediately after you create the timeline. Tracks are subassets of the timeline, but only add themselves to the AssetDatabase if the timeline is already part of it.
     
  3. oscar-schuurman

    oscar-schuurman

    Joined:
    Aug 4, 2017
    Posts:
    2
    Thank you! This has indeed solved the issue.