Hi there,
I am running into a serialization issue when dynamically creating TimelineClips for a TrackAsset in editor code.
I am creating the TimelineClip via
TimelineClip defaultClip = tracks[i].CreateDefaultClip();
and feeding into its asset field a cloned PlayableAsset,
var clone = ScriptableObject.Instantiate(asset);
defaultClip.asset = clone;
This seems to work well while the editor is running, but closing and reopening Unity again will see the asset field of the TimelineClip set to null. “DefaultClip” still retains all its other fields, like the start, duration of parentTrack information, but the cloned asset “clone” is nowhere to be found.
I tried dirtying the asset
EditorUtility.SetDirty(defaultClip.asset);
as well as the TrackAsset and the TimelineAsset, but the connection to the PlayableAsset keeps getting lost.
Since TimelineClip doesn’t inherit from UnityEngine.Object I can’t set it dirty. Is there some other way to serialized/save the TimelineClip and keeps it’s connection to the PlayableAsset?
I suspect the cloning of the PlayableAsset to be the root of the issue. Maybe there is a better way to duplicate a given PlayableAsset and feed it into a new TimelineClip?
Any help is much appreciated.