Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Saving and loading TimelineAsset from disc at runtime (in build)

Discussion in 'Timeline' started by 4quet, Jun 12, 2019.

  1. 4quet

    4quet

    Joined:
    Jan 18, 2016
    Posts:
    2
    Hello,
    In my project I'm using a Timeline dynamically populated with custom tracks and custom clips using the Playable API.

    I would like my built application to be able to save a TimelineAsset to disc (in Application.persistentDataPath for example) and load these same files to recreate a Timeline dynamically.
    Is there any way to accomplish this ?

    I know it could be possible inside the editor since I could use AssetDatabase but I'm looking for a way to do this in build mode.
    I also tried using JsonUtility but the serialization of TimelineAsset is incomplete using this method.

    Any help is much appreciated !
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Haven't tried this, so it's speculation, but I suspect if you are using a json serializer, you would need to serialize the timeline asset, all the tracks in the timeline, the playable assets on the clips in the timeline, all markers, any recorded animation clips on animation tracks and any animation clips on curves and tracks.

    Those are all the assets that are in the same file, and that part is usually handled by the asset database because it knows they are part of the same file. But that information is lost at runtime, so any serialization would need to take that into account.