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

Store trackAsset in ScriptableObject

Discussion in 'Timeline' started by zIyaGtVm, Mar 12, 2019.

  1. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    I write a dictionary in a ScriptableObject to store TimelineTrack & Clips assets so that I could refill them with different sets of sourceGameObjects or rebindingParams during runtime.
    I also write a ScriptableObject script to split a TimelineAsset by tracks & clips, and generate GUID for each element.
    so.png
    The problem is : sometimes the track/clip resolved result in dictionary doesn't get saved after Unity restart.
    Sometimes the Clips exposedName changes will lose after close Unity.
    I'v tried to use :
    Code (CSharp):
    1. EditorUtility.SetDirty(scriptableObject);
    2. AssetDatabase.SaveAssets();
    However it still doesn't work.
    Should I parse them to Json or other type so that the changes in dictionary could be detected?
    By the way I use Odin to serialize the ScriptableObject.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You may need to dirty the clip assets that has the exposed assets as well, if they aren't getting saved correctly. Just assigning the exposedName doesn't dirty the owner.

    In Timeline, the timeline itself is an asset, each track is an asset and easy individual PlayableAsset on the clip are assets, and need to be marked as dirty when they are changed. The clips themselves are part of the track, so if you change the clips start time, duration, etc... you need to dirty the track.

    Hope that helps.
     
    zIyaGtVm likes this.
  3. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    That's key point! You're great! Thanks for the quick reply and explanation! ;)